From 49ed0a2e1b1ff65184d405734b02da6b0a9ecfa0 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 18 May 2010 16:02:12 +0200 Subject: [PATCH] do not ignore qemuMonitorAddDrive failure; make uses identical There were three very similar uses of qemuMonitorAddDrive. This change makes the three 17-line sequences identical. * src/qemu/qemu_driver.c (qemudDomainAttachPciDiskDevice): Detect failure. Add VIR_WARN and braces. (qemudDomainAttachSCSIDisk): Add VIR_WARN and braces. (qemudDomainAttachUsbMassstorageDevice): Likewise. --- src/qemu/qemu_driver.c | 44 ++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 812860a97c..609fabe106 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6941,9 +6941,15 @@ static int qemudDomainAttachPciDiskDevice(struct qemud_driver *driver, qemuDomainObjEnterMonitorWithDriver(driver, vm); if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { ret = qemuMonitorAddDrive(priv->mon, drivestr); - if (ret == 0) - qemuMonitorAddDevice(priv->mon, devstr); - /* XXX remove the drive upon fail */ + if (ret == 0) { + ret = qemuMonitorAddDevice(priv->mon, devstr); + if (ret < 0) { + VIR_WARN(_("qemuMonitorAddDevice failed on %s (%s)"), + drivestr, devstr); + /* XXX should call 'drive_del' on error but this does not + exist yet */ + } + } } else { virDomainDevicePCIAddress guestAddr; ret = qemuMonitorAddPCIDisk(priv->mon, @@ -7164,12 +7170,16 @@ static int qemudDomainAttachSCSIDisk(struct qemud_driver *driver, qemuDomainObjEnterMonitorWithDriver(driver, vm); if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { - ret = qemuMonitorAddDrive(priv->mon, - drivestr); - if (ret == 0) - ret = qemuMonitorAddDevice(priv->mon, - devstr); - /* XXX should call 'drive_del' on error but this does not exist yet */ + ret = qemuMonitorAddDrive(priv->mon, drivestr); + if (ret == 0) { + ret = qemuMonitorAddDevice(priv->mon, devstr); + if (ret < 0) { + VIR_WARN(_("qemuMonitorAddDevice failed on %s (%s)"), + drivestr, devstr); + /* XXX should call 'drive_del' on error but this does not + exist yet */ + } + } } else { virDomainDeviceDriveAddress driveAddr; ret = qemuMonitorAttachDrive(priv->mon, @@ -7253,12 +7263,16 @@ static int qemudDomainAttachUsbMassstorageDevice(struct qemud_driver *driver, qemuDomainObjEnterMonitorWithDriver(driver, vm); if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { - ret = qemuMonitorAddDrive(priv->mon, - drivestr); - if (ret == 0) - ret = qemuMonitorAddDevice(priv->mon, - devstr); - /* XXX should call 'drive_del' on error but this does not exist yet */ + ret = qemuMonitorAddDrive(priv->mon, drivestr); + if (ret == 0) { + ret = qemuMonitorAddDevice(priv->mon, devstr); + if (ret < 0) { + VIR_WARN(_("qemuMonitorAddDevice failed on %s (%s)"), + drivestr, devstr); + /* XXX should call 'drive_del' on error but this does not + exist yet */ + } + } } else { ret = qemuMonitorAddUSBDisk(priv->mon, disk->src); }