mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
virt-xml: Handle VM names that look like id/uuid (bz 1679025)
Previously we assume they are id/uuid, so if it's actually the VM name then the command fails. Now we always check for a name first, https://bugzilla.redhat.com/show_bug.cgi?id=1679025
This commit is contained in:
parent
f23b01be53
commit
7afbb90b4d
@ -926,8 +926,8 @@ c.add_compare("--build-xml --cpu pentium3,+x2apic", "build-cpu")
|
|||||||
c.add_compare("--build-xml --tpm /dev/tpm", "build-tpm")
|
c.add_compare("--build-xml --tpm /dev/tpm", "build-tpm")
|
||||||
c.add_compare("--build-xml --blkiotune weight=100,device_path=/dev/sdf,device_weight=200", "build-blkiotune")
|
c.add_compare("--build-xml --blkiotune weight=100,device_path=/dev/sdf,device_weight=200", "build-blkiotune")
|
||||||
c.add_compare("--build-xml --idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10", "build-idmap")
|
c.add_compare("--build-xml --idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10", "build-idmap")
|
||||||
c.add_compare("test --edit --boot network,cdrom", "edit-bootorder")
|
c.add_compare("4a64cc71-19c4-2fd0-2323-3050941ea3c3 --edit --boot network,cdrom", "edit-bootorder") # basic bootorder test, also using UUID lookup
|
||||||
c.add_compare("--confirm test --edit --cpu host-passthrough", "prompt-response")
|
c.add_compare("--confirm 1 --edit --cpu host-passthrough", "prompt-response") # prompt response, also using domid lookup
|
||||||
c.add_compare("--edit --print-diff --qemu-commandline clearxml=yes", "edit-clearxml-qemu-commandline", input_file=(XMLDIR + "/virtxml-qemu-commandline-clear.xml"))
|
c.add_compare("--edit --print-diff --qemu-commandline clearxml=yes", "edit-clearxml-qemu-commandline", input_file=(XMLDIR + "/virtxml-qemu-commandline-clear.xml"))
|
||||||
c.add_compare("--connect %(URI-KVM)s test-hyperv-uefi --edit --boot uefi", "hyperv-uefi-collision")
|
c.add_compare("--connect %(URI-KVM)s test-hyperv-uefi --edit --boot uefi", "hyperv-uefi-collision")
|
||||||
|
|
||||||
|
16
virt-xml
16
virt-xml
@ -74,12 +74,18 @@ def get_domain_and_guest(conn, domstr):
|
|||||||
isuuid = bool(re.match(uuidre, domstr))
|
isuuid = bool(re.match(uuidre, domstr))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if isint:
|
domain = None
|
||||||
domain = conn.lookupByID(int(domstr))
|
try:
|
||||||
elif isuuid:
|
|
||||||
domain = conn.lookupByUUIDString(domstr)
|
|
||||||
else:
|
|
||||||
domain = conn.lookupByName(domstr)
|
domain = conn.lookupByName(domstr)
|
||||||
|
except Exception:
|
||||||
|
# Incase the VM has a UUID or ID for a name
|
||||||
|
logging.debug("Error looking up domain by name", exc_info=True)
|
||||||
|
if isint:
|
||||||
|
domain = conn.lookupByID(int(domstr))
|
||||||
|
elif isuuid:
|
||||||
|
domain = conn.lookupByUUIDString(domstr)
|
||||||
|
else:
|
||||||
|
raise
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
fail(_("Could not find domain '%s': %s") % (domstr, e))
|
fail(_("Could not find domain '%s': %s") % (domstr, e))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user