diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 6dd75e224d..7a8162bf7a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -11054,6 +11054,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, { xmlNodePtr tmp = NULL; xmlNodePtr source = NULL; + xmlNodePtr backingStore = NULL; xmlNodePtr target_node = NULL; xmlNodePtr text_node = NULL; char *device_type = NULL; @@ -11094,13 +11095,22 @@ virshUpdateDiskXML(xmlNodePtr disk_node, if (xmlStrEqual(tmp->name, BAD_CAST "target")) target_node = tmp; + if (xmlStrEqual(tmp->name, BAD_CAST "backingStore")) + backingStore = tmp; + /* * We've found all we needed. */ - if (source && target_node) + if (source && target_node && backingStore) break; } + /* drop the subtree since it would become invalid */ + if (backingStore) { + xmlUnlinkNode(backingStore); + xmlFreeNode(backingStore); + } + if (type == VIRSH_UPDATE_DISK_XML_EJECT) { if (!source) { vshError(NULL, _("The disk device '%s' doesn't have media"), target);