Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
libvirt-python: rename a domain with empty string won't raise exception, and restart libvirtd that domain will disappear.
Version-Release number of selected component (if applicable):
libvirt-1.3.2-1.el7.x86_64
libvirt-python-1.3.2-1.el7.x86_64
How reproducible:
100%
Steps to Reproduce:
1.Create a guest vm and shut it down.
look like this:
# virsh list --all
Id Name State
----------------------------------------------------
- libvirt_test_api shut off
2.run follow script in python
>>> import libvirt
>>> conn = libvirt.open()
>>> dom = conn.lookupByName('libvirt_test_api')
>>> dom.rename('', 0)
0
3.Domain was renamed, name is empty in virsh
# virsh list --all
Id Name State
----------------------------------------------------
- shut off
4.Restart libvirtd and domain disappeard
# systemctl restart libvirtd
# virsh list --all
Id Name State
----------------------------------------------------
Actual results:
Domain was renamed to a empty name and disappeared after restart libvirtd
Expected results:
Exception raises when try to rename a domain with empty string.
Additional info:
1.virsh gives error on empty domain name:
# virsh domrename 'libvirt_test_api' ''
error: Failed to get option 'new-name': Option argument is empty
2.At libvirt/src/libvirt-domain.c:8759
virCheckNonNullArgGoto(new_name, error);
libvirt only check is 'new_name' is a NULL pointer, didn't check if the string it pointing is a empty string.
replace with virCheckNonEmptyStringArgGoto(new_name, error) should fix it, but I'm not sure if it is the hyper-visor's driver's job to check it, or libvirt-python should check it.
Moving to libvirt as the bug is in the API itself.
(In reply to Kairui Song from comment #0)
>
> Additional info:
> 1.virsh gives error on empty domain name:
>
> # virsh domrename 'libvirt_test_api' ''
> error: Failed to get option 'new-name': Option argument is empty
This is due to the implementation of virsh, the API allows it, which is accessible directly via the python binding.
Comment 4Martin Kletzander
2016-06-22 15:48:33 UTC
I can reproduce this issue.
verify with libvirt-2.0.0-1.el7.x86_64
step:
1. use python
python
Python 2.7.5 (default, May 4 2016, 07:14:23)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open()
>>> dom = conn.lookupByName('q35')
>>> dom.rename('', 0)
libvirt: Domain Config error : string new_name in virDomainRename must not be empty
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/libvirt.py", line 2126, in rename
if ret == -1: raise libvirtError ('virDomainRename() failed', dom=self)
libvirt.libvirtError: string new_name in virDomainRename must not be empty
>>>
2. use virsh
# virsh domrename q35 ''
error: Failed to get option 'new-name': Option argument is empty
# virsh domrename q35 ' '
Domain successfully renamed
# virsh list --all
Id Name State
----------------------------------------------------
- shut off
# systemctl restart libvirtd
# virsh list --all
Id Name State
----------------------------------------------------
- shut off
# virsh domrename ' ' q35
Domain successfully renamed
# virsh list --all
Id Name State
----------------------------------------------------
- q35 shut off
worked as expect, move to verified.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://rhn.redhat.com/errata/RHSA-2016-2577.html
Description of problem: libvirt-python: rename a domain with empty string won't raise exception, and restart libvirtd that domain will disappear. Version-Release number of selected component (if applicable): libvirt-1.3.2-1.el7.x86_64 libvirt-python-1.3.2-1.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1.Create a guest vm and shut it down. look like this: # virsh list --all Id Name State ---------------------------------------------------- - libvirt_test_api shut off 2.run follow script in python >>> import libvirt >>> conn = libvirt.open() >>> dom = conn.lookupByName('libvirt_test_api') >>> dom.rename('', 0) 0 3.Domain was renamed, name is empty in virsh # virsh list --all Id Name State ---------------------------------------------------- - shut off 4.Restart libvirtd and domain disappeard # systemctl restart libvirtd # virsh list --all Id Name State ---------------------------------------------------- Actual results: Domain was renamed to a empty name and disappeared after restart libvirtd Expected results: Exception raises when try to rename a domain with empty string. Additional info: 1.virsh gives error on empty domain name: # virsh domrename 'libvirt_test_api' '' error: Failed to get option 'new-name': Option argument is empty 2.At libvirt/src/libvirt-domain.c:8759 virCheckNonNullArgGoto(new_name, error); libvirt only check is 'new_name' is a NULL pointer, didn't check if the string it pointing is a empty string. replace with virCheckNonEmptyStringArgGoto(new_name, error) should fix it, but I'm not sure if it is the hyper-visor's driver's job to check it, or libvirt-python should check it.