On 04/21/2011 01:25 AM, KAMEZAWA Hiroyuki wrote: > This patch strips reusable part of qemudDomainUpdateDeviceFlags() > and consolidate it to qemudDomainModifyDeviceFlags(). > No functional changes. > > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> > > Changelog: v10->v11 > - fixed qemuTeardownDiskCgroup() > > > - virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE | > - VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1); > + switch (action) { > + case QEMUD_DEVICE_ATTACH: > + case QEMUD_DEVICE_DETACH: > + virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE | > + VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1); > + break; > + case QEMUD_DEVICE_UPDATE: > + virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_CURRENT | > + VIR_DOMAIN_DEVICE_MODIFY_LIVE | > + VIR_DOMAIN_DEVICE_MODIFY_CONFIG | > + VIR_DOMAIN_DEVICE_MODIFY_FORCE, -1); > + break; > + default: > + break; This lets an invalid action through without warning. And _CURRENT is 0, so it's redundant. I shrunk it a bit. More qemud/qemu renaming. ACK, and pushed with this squashed in: diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c index b0ca3ce..771678e 100644 --- i/src/qemu/qemu_driver.c +++ w/src/qemu/qemu_driver.c @@ -3999,11 +3999,11 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, } static int -qemudDomainChangeDiskMediaLive(virDomainObjPtr vm, - virDomainDeviceDefPtr dev, - struct qemud_driver *driver, - virBitmapPtr qemuCaps, - bool force) +qemuDomainChangeDiskMediaLive(virDomainObjPtr vm, + virDomainDeviceDefPtr dev, + struct qemud_driver *driver, + virBitmapPtr qemuCaps, + bool force) { virDomainDiskDefPtr disk = dev->data.disk; virCgroupPtr cgroup = NULL; @@ -4046,18 +4046,19 @@ end: return ret; } -static int qemudDomainUpdateDeviceLive(virDomainObjPtr vm, - virDomainDeviceDefPtr dev, - virDomainPtr dom, - virBitmapPtr qemuCaps, - bool force) +static int +qemuDomainUpdateDeviceLive(virDomainObjPtr vm, + virDomainDeviceDefPtr dev, + virDomainPtr dom, + virBitmapPtr qemuCaps, + bool force) { struct qemud_driver *driver = dom->conn->privateData; int ret = -1; switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: - ret = qemudDomainChangeDiskMediaLive(vm, dev, driver, qemuCaps, force); + ret = qemuDomainChangeDiskMediaLive(vm, dev, driver, qemuCaps, force); break; case VIR_DOMAIN_DEVICE_GRAPHICS: ret = qemuDomainChangeGraphics(driver, vm, dev->data.graphics); @@ -4091,21 +4092,10 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0; int ret = -1; - switch (action) { - case QEMU_DEVICE_ATTACH: - case QEMU_DEVICE_DETACH: - virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE | - VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1); - break; - case QEMU_DEVICE_UPDATE: - virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_CURRENT | - VIR_DOMAIN_DEVICE_MODIFY_LIVE | - VIR_DOMAIN_DEVICE_MODIFY_CONFIG | - VIR_DOMAIN_DEVICE_MODIFY_FORCE, -1); - break; - default: - break; - } + virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_LIVE | + VIR_DOMAIN_DEVICE_MODIFY_CONFIG | + (action == QEMU_DEVICE_UPDATE ? + VIR_DOMAIN_DEVICE_MODIFY_FORCE : 0), -1); if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) { qemuReportError(VIR_ERR_OPERATION_INVALID, @@ -4150,9 +4140,11 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml, ret = qemuDomainDetachDeviceLive(vm, dev, dom, qemuCaps); break; case QEMU_DEVICE_UPDATE: - ret = qemudDomainUpdateDeviceLive(vm, dev, dom, qemuCaps, force); + ret = qemuDomainUpdateDeviceLive(vm, dev, dom, qemuCaps, force); break; default: + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown domain modify action %d"), action); break; } -- Eric Blake eblake@xxxxxxxxxx +1-801-349-2682 Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature