From 2d3557b251994c820fd693d164ee4216f93a31fb Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 20 Apr 2016 17:11:52 +0200 Subject: [PATCH] conf: disk: Move validation of disk bus vs disk type --- src/conf/domain_conf.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8ac308ccc2..f76a8b7f87 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6925,6 +6925,22 @@ virDomainDiskDefValidate(const virDomainDiskDef *def) } } + if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && + def->bus != VIR_DOMAIN_DISK_BUS_FDC) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid bus type '%s' for floppy disk"), + virDomainDiskBusTypeToString(def->bus)); + return -1; + } + + if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && + def->bus == VIR_DOMAIN_DISK_BUS_FDC) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid bus type '%s' for disk"), + virDomainDiskBusTypeToString(def->bus)); + return -1; + } + return 0; } @@ -7415,19 +7431,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } } - if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && - def->bus != VIR_DOMAIN_DISK_BUS_FDC) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid bus type '%s' for floppy disk"), bus); - goto error; - } - if (def->device != VIR_DOMAIN_DISK_DEVICE_FLOPPY && - def->bus == VIR_DOMAIN_DISK_BUS_FDC) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid bus type '%s' for disk"), bus); - goto error; - } - if (devaddr) { if (virDomainParseLegacyDeviceAddress(devaddr, &def->info.addr.pci) < 0) {