Hi, The following patch was generated with format patch & checked with syntax-check. It is really short and adds a new function virDomainFSInsert which is called when Qemu driver is requested t attach a filesystem device. Matt
From f8c0612c48c06c61199693743d98c251ba4d887e Mon Sep 17 00:00:00 2001 From: Matt <mattator@xxxxxxxxx> Date: Mon, 3 Feb 2014 17:42:56 +0100 Subject: [PATCH] This commit allows to register <filesystem> in qemu via the attach_device function (which would previsouly return an error). For this purpose I've introduced a new function "virDomainFSInsert" and added the necessary code in the qemu driver. It compares filesystems based on their "destination" folder. So if 2 filesystems share a same destination, they are considered equal and the Qemu driver would reject a new insertion. --- src/conf/domain_conf.c | 12 ++++++++++++ src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + src/qemu/qemu_driver.c | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 28e24f9..3f4dbfe 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17933,6 +17933,18 @@ virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, return 0; } + +int +virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs) +{ + + if (VIR_REALLOC_N(def->fss, def->nfss+1) < 0) + return -1; + + def->fss[def->nfss++] = fs; + return 0; +} + virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d8f2e49..d749e68 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2555,6 +2555,7 @@ int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, int *devIdx); virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def); +int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs); int virDomainFSIndexByName(virDomainDefPtr def, const char *name); int virDomainVideoDefaultType(const virDomainDef *def); int virDomainVideoDefaultRAM(const virDomainDef *def, int type); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 1a8d088..e872960 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -221,6 +221,7 @@ virDomainFeatureStateTypeFromString; virDomainFeatureStateTypeToString; virDomainFSDefFree; virDomainFSIndexByName; +virDomainFSInsert; virDomainFSTypeFromString; virDomainFSTypeToString; virDomainFSWrpolicyTypeFromString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0128356..f2bac0d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6606,6 +6606,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps, virDomainHostdevDefPtr hostdev; virDomainLeaseDefPtr lease; virDomainControllerDefPtr controller; + virDomainFSDefPtr fs; switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: @@ -6687,6 +6688,23 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps, dev->data.chr = NULL; break; + case VIR_DOMAIN_DEVICE_FS: + { + fs = dev->data.fs; + if (virDomainFSIndexByName(vmdef, fs->dst) >= 0) { + VIR_INFO("Identical FS found"); + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("Target already exists")); + return -1; + } + + if (virDomainFSInsert(vmdef, fs) < 0) { + return -1; + } + dev->data.fs = NULL; + } + break; + default: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("persistent attach of device '%s' is not supported"), -- 1.8.3.2
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list