From patchwork Tue Oct 20 09:17:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 532935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7DC5B1401E7 for ; Tue, 20 Oct 2015 23:15:42 +1100 (AEDT) Received: from localhost ([::1]:44685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoT3U-0002fh-QA for incoming@patchwork.ozlabs.org; Tue, 20 Oct 2015 05:18:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoT2c-0002HS-5Q for qemu-devel@nongnu.org; Tue, 20 Oct 2015 05:17:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoT2Y-0005Pt-1a for qemu-devel@nongnu.org; Tue, 20 Oct 2015 05:17:10 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:42602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoT2X-0005Pf-Q1 for qemu-devel@nongnu.org; Tue, 20 Oct 2015 05:17:05 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 20 Oct 2015 10:17:04 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 20 Oct 2015 10:17:02 +0100 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: gkurz@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9D2CE1B0805F for ; Tue, 20 Oct 2015 10:17:09 +0100 (BST) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9K9H2ek25690178 for ; Tue, 20 Oct 2015 09:17:02 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9K9H1Re023590 for ; Tue, 20 Oct 2015 03:17:02 -0600 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t9K9H1PL023581; Tue, 20 Oct 2015 03:17:01 -0600 Received: from bahia.huguette.org (icon-9-164-138-165.megacenter.de.ibm.com [9.164.138.165]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id BAF24220083; Tue, 20 Oct 2015 11:17:00 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 20 Oct 2015 11:17:00 +0200 Message-ID: <20151020091700.25419.56847.stgit@bahia.huguette.org> In-Reply-To: <20151020091640.25419.99985.stgit@bahia.huguette.org> References: <20151020091640.25419.99985.stgit@bahia.huguette.org> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15102009-0013-0000-0000-000007616534 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.109 Cc: Cornelia Huck , "Michael S. Tsirkin" , Alexander Graf , Andreas =?utf-8?q?F=C3=A4rber?= , aneesh.kumar@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v3 3/5] virtio-9p: block hot-unplug when device is active X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hot-unplug of an active virtio-9p device is not currently supported. Until we have that, let's block hot-unplugging when the 9p share is mounted in the guest. This patch implements a hot-unplug blocker feature like we already have for migration. Both virtio-9p-pci and virtio-9p-ccw were adapted accordingly. Signed-off-by: Greg Kurz --- hw/9pfs/virtio-9p.c | 14 ++++++++++++++ hw/9pfs/virtio-9p.h | 2 ++ hw/s390x/virtio-ccw.c | 8 ++++++++ hw/virtio/virtio-pci.c | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c index f972731f5a8d..bbf39ed33983 100644 --- a/hw/9pfs/virtio-9p.c +++ b/hw/9pfs/virtio-9p.c @@ -345,6 +345,7 @@ static int put_fid(V9fsPDU *pdu, V9fsFidState *fidp) migrate_del_blocker(pdu->s->migration_blocker); error_free(pdu->s->migration_blocker); pdu->s->migration_blocker = NULL; + pdu->s->unplug_is_blocked = false; } } return free_fid(pdu, fidp); @@ -991,6 +992,7 @@ static void v9fs_attach(void *opaque) "Migration is disabled when VirtFS export path '%s' is mounted in the guest using mount_tag '%s'", s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag); migrate_add_blocker(s->migration_blocker); + s->unplug_is_blocked = true; } out: put_fid(pdu, fidp); @@ -3288,6 +3290,18 @@ void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq) free_pdu(s, pdu); } +bool v9fs_unplug_is_blocked(V9fsState *s, Error **errp) +{ + if (s->unplug_is_blocked) { + error_setg(errp, + "Unplug is disabled when VirtFS export path '%s' is mounted" + " in the guest using mount_tag '%s'", + s->ctx.fs_root ? s->ctx.fs_root : "NULL", s->tag); + return false; + } + return true; +} + static void __attribute__((__constructor__)) virtio_9p_set_fd_limit(void) { struct rlimit rlim; diff --git a/hw/9pfs/virtio-9p.h b/hw/9pfs/virtio-9p.h index 2e7d48857083..8d4cbed2a5c4 100644 --- a/hw/9pfs/virtio-9p.h +++ b/hw/9pfs/virtio-9p.h @@ -218,6 +218,7 @@ typedef struct V9fsState CoRwlock rename_lock; int32_t root_fid; Error *migration_blocker; + bool unplug_is_blocked; V9fsConf fsconf; } V9fsState; @@ -381,6 +382,7 @@ extern void v9fs_path_free(V9fsPath *path); extern void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs); extern int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath, const char *name, V9fsPath *path); +extern bool v9fs_unplug_is_blocked(V9fsState *s, Error **errp); #define pdu_marshal(pdu, offset, fmt, args...) \ v9fs_marshal(pdu->elem.in_sg, pdu->elem.in_num, offset, 1, fmt, ##args) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index fb103b78ac28..5c13072ec96e 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1924,6 +1924,13 @@ static void virtio_ccw_9p_realize(VirtioCcwDevice *ccw_dev, Error **errp) } } +static bool virtio_ccw_9p_unplug_is_blocked(DeviceState *dev, Error **errp) +{ + V9fsCCWState *v9fs_ccw_dev = VIRTIO_9P_CCW(dev); + + return v9fs_unplug_is_blocked(&v9fs_ccw_dev->vdev, errp); +} + static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -1931,6 +1938,7 @@ static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data) k->exit = virtio_ccw_exit; k->realize = virtio_ccw_9p_realize; + dc->unplug_is_blocked = virtio_ccw_9p_unplug_is_blocked; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_9p_properties; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index e5c406d1d255..bf0d516528ee 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1015,6 +1015,13 @@ static void virtio_9p_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) object_property_set_bool(OBJECT(vdev), true, "realized", errp); } +static bool virtio_9p_pci_unplug_is_blocked(DeviceState *dev, Error **errp) +{ + V9fsPCIState *v9fs_pci_dev = VIRTIO_9P_PCI(dev); + + return v9fs_unplug_is_blocked(&v9fs_pci_dev->vdev, errp); +} + static Property virtio_9p_pci_properties[] = { DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), @@ -1035,6 +1042,7 @@ static void virtio_9p_pci_class_init(ObjectClass *klass, void *data) pcidev_k->class_id = 0x2; set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); dc->props = virtio_9p_pci_properties; + dc->unplug_is_blocked = virtio_9p_pci_unplug_is_blocked; } static void virtio_9p_pci_instance_init(Object *obj)