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.
This commit is contained in:
Jim Meyering 2010-05-18 16:02:12 +02:00
parent d564fcb3e1
commit 49ed0a2e1b

View File

@ -6941,9 +6941,15 @@ static int qemudDomainAttachPciDiskDevice(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm); qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
ret = qemuMonitorAddDrive(priv->mon, drivestr); ret = qemuMonitorAddDrive(priv->mon, drivestr);
if (ret == 0) if (ret == 0) {
qemuMonitorAddDevice(priv->mon, devstr); ret = qemuMonitorAddDevice(priv->mon, devstr);
/* XXX remove the drive upon fail */ 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 { } else {
virDomainDevicePCIAddress guestAddr; virDomainDevicePCIAddress guestAddr;
ret = qemuMonitorAddPCIDisk(priv->mon, ret = qemuMonitorAddPCIDisk(priv->mon,
@ -7164,12 +7170,16 @@ static int qemudDomainAttachSCSIDisk(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm); qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
ret = qemuMonitorAddDrive(priv->mon, ret = qemuMonitorAddDrive(priv->mon, drivestr);
drivestr); if (ret == 0) {
if (ret == 0) ret = qemuMonitorAddDevice(priv->mon, devstr);
ret = qemuMonitorAddDevice(priv->mon, if (ret < 0) {
devstr); VIR_WARN(_("qemuMonitorAddDevice failed on %s (%s)"),
/* XXX should call 'drive_del' on error but this does not exist yet */ drivestr, devstr);
/* XXX should call 'drive_del' on error but this does not
exist yet */
}
}
} else { } else {
virDomainDeviceDriveAddress driveAddr; virDomainDeviceDriveAddress driveAddr;
ret = qemuMonitorAttachDrive(priv->mon, ret = qemuMonitorAttachDrive(priv->mon,
@ -7253,12 +7263,16 @@ static int qemudDomainAttachUsbMassstorageDevice(struct qemud_driver *driver,
qemuDomainObjEnterMonitorWithDriver(driver, vm); qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) { if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
ret = qemuMonitorAddDrive(priv->mon, ret = qemuMonitorAddDrive(priv->mon, drivestr);
drivestr); if (ret == 0) {
if (ret == 0) ret = qemuMonitorAddDevice(priv->mon, devstr);
ret = qemuMonitorAddDevice(priv->mon, if (ret < 0) {
devstr); VIR_WARN(_("qemuMonitorAddDevice failed on %s (%s)"),
/* XXX should call 'drive_del' on error but this does not exist yet */ drivestr, devstr);
/* XXX should call 'drive_del' on error but this does not
exist yet */
}
}
} else { } else {
ret = qemuMonitorAddUSBDisk(priv->mon, disk->src); ret = qemuMonitorAddUSBDisk(priv->mon, disk->src);
} }