From 05eab1bf9a13d24e4de9a665ab8b69c1fe9dc1ec Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 27 May 2016 12:34:14 +0200 Subject: [PATCH] conf: Move disk info validator to the domain conf validator Since it will not be called from outside of conf we can unexport it too if we move it to the appropriate place. Test suite change is necessary since the error will be reported sooner now. --- src/conf/domain_conf.c | 45 +++++++++++++++++++++------------------- src/conf/domain_conf.h | 6 ++---- src/libvirt_private.syms | 1 - src/qemu/qemu_process.c | 11 +++------- tests/qemuxml2argvtest.c | 6 +++--- 5 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index efb85febcc..d0d040a76b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4573,8 +4573,29 @@ virDomainDefValidateDeviceIterator(virDomainDefPtr def, static int -virDomainDefValidateInternal(const virDomainDef *def ATTRIBUTE_UNUSED) +virDomainDefCheckDuplicateDiskInfo(const virDomainDef *def) { + size_t i; + size_t j; + + for (i = 0; i < def->ndisks; i++) { + for (j = i + 1; j < def->ndisks; j++) { + if (virDomainDiskDefCheckDuplicateInfo(def->disks[i], + def->disks[j]) < 0) + return -1; + } + } + + return 0; +} + + +static int +virDomainDefValidateInternal(const virDomainDef *def) +{ + if (virDomainDefCheckDuplicateDiskInfo(def) < 0) + return -1; + return 0; } @@ -24583,8 +24604,8 @@ virDomainDefNeedsPlacementAdvice(virDomainDefPtr def) int -virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a, - virDomainDiskDefPtr b) +virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a, + const virDomainDiskDef *b) { if (STREQ(a->dst, b->dst)) { virReportError(VIR_ERR_XML_ERROR, @@ -24613,24 +24634,6 @@ virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a, } -int -virDomainDefCheckDuplicateDiskInfo(virDomainDefPtr def) -{ - size_t i; - size_t j; - - for (i = 0; i < def->ndisks; i++) { - for (j = i + 1; j < def->ndisks; j++) { - if (virDomainDiskDefCheckDuplicateInfo(def->disks[i], - def->disks[j]) < 0) - return -1; - } - } - - return 0; -} - - /** * virDomainDefHasMemballoon: * @def: domain definition diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d62d99bf2f..8938ceef9f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3067,11 +3067,9 @@ virDomainParseMemory(const char *xpath, bool virDomainDefNeedsPlacementAdvice(virDomainDefPtr def) ATTRIBUTE_NONNULL(1); -int virDomainDiskDefCheckDuplicateInfo(virDomainDiskDefPtr a, - virDomainDiskDefPtr b) +int virDomainDiskDefCheckDuplicateInfo(const virDomainDiskDef *a, + const virDomainDiskDef *b) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -int virDomainDefCheckDuplicateDiskInfo(virDomainDefPtr def) - ATTRIBUTE_NONNULL(1); int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, int maplen, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8f664ef60f..3fd042b8f1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -207,7 +207,6 @@ virDomainDefAddController; virDomainDefAddImplicitDevices; virDomainDefAddUSBController; virDomainDefCheckABIStability; -virDomainDefCheckDuplicateDiskInfo; virDomainDefClearCCWAddresses; virDomainDefClearDeviceAliases; virDomainDefClearPCIAddresses; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c1f71dd212..799a37e3ea 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4303,14 +4303,9 @@ qemuProcessStartValidateXML(virQEMUDriverPtr driver, /* checks below should not be executed when starting a qemu process for a * VM that was running before (migration, snapshots, save). It's more * important to start such VM than keep the configuration clean */ - if ((flags & VIR_QEMU_PROCESS_START_NEW)) { - if (virDomainDefValidate(vm->def, caps, 0, driver->xmlopt) < 0) - return -1; - - if (virDomainDefCheckDuplicateDiskInfo(vm->def) < 0) - return -1; - } - + if ((flags & VIR_QEMU_PROCESS_START_NEW) && + virDomainDefValidate(vm->def, caps, 0, driver->xmlopt) < 0) + return -1; if (vm->def->mem.min_guarantee) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b2cde8e542..f009d09b9f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -876,9 +876,9 @@ mymain(void) DO_TEST("disk-drive-discard", QEMU_CAPS_DRIVE_DISCARD); DO_TEST("disk-snapshot", NONE); - DO_TEST_FAILURE("disk-same-targets", - QEMU_CAPS_SCSI_LSI, - QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG); + DO_TEST_PARSE_ERROR("disk-same-targets", + QEMU_CAPS_SCSI_LSI, + QEMU_CAPS_DEVICE_USB_STORAGE, QEMU_CAPS_NODEFCONFIG); DO_TEST("event_idx", QEMU_CAPS_VIRTIO_BLK_EVENT_IDX, QEMU_CAPS_VIRTIO_NET_EVENT_IDX,