From 33fd5cc8aab72a2a4d59fc3264700f0fee45ddd0 Mon Sep 17 00:00:00 2001 Message-Id: <33fd5cc8aab72a2a4d59fc3264700f0fee45ddd0.1389183250.git.jdenemar@redhat.com> From: Peter Krempa Date: Wed, 8 Jan 2014 10:47:22 +0100 Subject: [PATCH] virsh: Don't use legacy API if --current is used on device hot(un)plug https://bugzilla.redhat.com/show_bug.cgi?id=1049529 The legacy virDomainAttachDevice and virDomainDetachDevice operate only on active domains. When a user specified --current flag with an inactive domain the old API was used and reported an error. Fix it by calling the new API if --current is specified explicitly. (cherry picked from commit 0bb64df1fcbf8248d8b71c44c8c882ae7b17d846) Conflicts: tools/virsh-domain.c - commit 3df33d7ad52d27bf9a41ab07e2c0ab6313 Signed-off-by: Jiri Denemark --- tools/virsh-domain.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index b017ec3..132b359 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -230,7 +230,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if (flags) + if (flags || current) rv = virDomainAttachDeviceFlags(dom, buffer, flags); else rv = virDomainAttachDevice(dom, buffer); @@ -672,7 +672,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) virDomainIsActive(dom) == 1) flags |= VIR_DOMAIN_AFFECT_LIVE; - if (flags) + if (flags || current) ret = virDomainAttachDeviceFlags(dom, xml, flags); else ret = virDomainAttachDevice(dom, xml); @@ -926,7 +926,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) xml = virBufferContentAndReset(&buf); - if (flags) + if (flags || current) ret = virDomainAttachDeviceFlags(dom, xml, flags); else ret = virDomainAttachDevice(dom, xml); @@ -9425,7 +9425,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if (flags != 0) + if (flags != 0 || current) ret = virDomainDetachDeviceFlags(dom, buffer, flags); else ret = virDomainDetachDevice(dom, buffer); @@ -9706,7 +9706,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if (flags != 0) { + if (flags != 0 || current) { ret = virDomainDetachDeviceFlags(dom, (char *)xmlBufferContent(xml_buf), flags); @@ -10036,7 +10036,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) VSH_PREPARE_DISK_XML_NONE))) goto cleanup; - if (flags != 0) + if (flags != 0 || current) ret = virDomainDetachDeviceFlags(dom, disk_xml, flags); else ret = virDomainDetachDevice(dom, disk_xml); -- 1.8.5.2