Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix virt.full_info #176

Merged
merged 2 commits into from
Sep 3, 2019

Conversation

cbosdo
Copy link
Contributor

@cbosdo cbosdo commented Aug 29, 2019

What does this PR do?

While running virt.full_info module function, several errors happened:

'ERROR: The VM "<libvirt.virDomain object at 0x7fad04208650>" is not present'

and

    The minion function caused an exception: Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1673, in _thread_return
    return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
  File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
    return func(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2411, in full_info
    'vm_info': vm_info()}
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2020, in vm_info
    info[domain.name()] = _info(domain)
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2004, in _info
    'disks': _get_disks(dom),
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 465, in _get_disks
    output = _parse_qemu_img_info(qemu_output)
  File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 287, in _parse_qemu_img_info
    raw_infos = salt.utils.json.loads(info)
  File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 92, in loads
    return json_module.loads(s, **kwargs)
  File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This PR fixes both of these issues.

What issues does this PR fix or reference?

This is a backport of saltstack/salt#54335
Fixes bsc#1146382

In some places in the virt module, the get_xml function was called with
a domain object, leading to runtime errors like the following one:

'ERROR: The VM "<libvirt.virDomain object at 0x7fad04208650>" is not present'
When getting VM disks informations on a running VM, the following error
occured:

    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1673, in _thread_return
        return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
      File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
        return func(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2411, in full_info
        'vm_info': vm_info()}
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2020, in vm_info
        info[domain.name()] = _info(domain)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2004, in _info
        'disks': _get_disks(dom),
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 465, in _get_disks
        output = _parse_qemu_img_info(qemu_output)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 287, in _parse_qemu_img_info
        raw_infos = salt.utils.json.loads(info)
      File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 92, in loads
        return json_module.loads(s, **kwargs)
      File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is due to the fact that qemu-img can't get infos on a disk that is
already used like by a running VM. Using the qemu-img -U flag gets it
running in all cases.
@brejoc brejoc merged commit 4ce0bc5 into openSUSE:openSUSE-2019.2.0 Sep 3, 2019
@cbosdo cbosdo deleted the openSUSE-2019.2.0-pr54335 branch September 3, 2019 16:39
meaksh pushed a commit that referenced this pull request Oct 1, 2019
* virt.get_xml doesn't take a domain object

In some places in the virt module, the get_xml function was called with
a domain object, leading to runtime errors like the following one:

'ERROR: The VM "<libvirt.virDomain object at 0x7fad04208650>" is not present'

* qemu-img info needs -U flag on running VMs

When getting VM disks informations on a running VM, the following error
occured:

    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1673, in _thread_return
        return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
      File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
        return func(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2411, in full_info
        'vm_info': vm_info()}
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2020, in vm_info
        info[domain.name()] = _info(domain)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2004, in _info
        'disks': _get_disks(dom),
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 465, in _get_disks
        output = _parse_qemu_img_info(qemu_output)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 287, in _parse_qemu_img_info
        raw_infos = salt.utils.json.loads(info)
      File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 92, in loads
        return json_module.loads(s, **kwargs)
      File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is due to the fact that qemu-img can't get infos on a disk that is
already used like by a running VM. Using the qemu-img -U flag gets it
running in all cases.
brejoc pushed a commit that referenced this pull request Nov 15, 2019
* virt.get_xml doesn't take a domain object

In some places in the virt module, the get_xml function was called with
a domain object, leading to runtime errors like the following one:

'ERROR: The VM "<libvirt.virDomain object at 0x7fad04208650>" is not present'

* qemu-img info needs -U flag on running VMs

When getting VM disks informations on a running VM, the following error
occured:

    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1673, in _thread_return
        return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
      File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
        return func(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2411, in full_info
        'vm_info': vm_info()}
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2020, in vm_info
        info[domain.name()] = _info(domain)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2004, in _info
        'disks': _get_disks(dom),
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 465, in _get_disks
        output = _parse_qemu_img_info(qemu_output)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 287, in _parse_qemu_img_info
        raw_infos = salt.utils.json.loads(info)
      File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 92, in loads
        return json_module.loads(s, **kwargs)
      File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is due to the fact that qemu-img can't get infos on a disk that is
already used like by a running VM. Using the qemu-img -U flag gets it
running in all cases.
dincamihai pushed a commit that referenced this pull request Nov 19, 2019
* virt.get_xml doesn't take a domain object

In some places in the virt module, the get_xml function was called with
a domain object, leading to runtime errors like the following one:

'ERROR: The VM "<libvirt.virDomain object at 0x7fad04208650>" is not present'

* qemu-img info needs -U flag on running VMs

When getting VM disks informations on a running VM, the following error
occured:

    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1673, in _thread_return
        return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
      File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
        return func(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2411, in full_info
        'vm_info': vm_info()}
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2020, in vm_info
        info[domain.name()] = _info(domain)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2004, in _info
        'disks': _get_disks(dom),
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 465, in _get_disks
        output = _parse_qemu_img_info(qemu_output)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 287, in _parse_qemu_img_info
        raw_infos = salt.utils.json.loads(info)
      File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 92, in loads
        return json_module.loads(s, **kwargs)
      File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is due to the fact that qemu-img can't get infos on a disk that is
already used like by a running VM. Using the qemu-img -U flag gets it
running in all cases.
brejoc pushed a commit that referenced this pull request Jan 31, 2020
* virt.get_xml doesn't take a domain object

In some places in the virt module, the get_xml function was called with
a domain object, leading to runtime errors like the following one:

'ERROR: The VM "<libvirt.virDomain object at 0x7fad04208650>" is not present'

* qemu-img info needs -U flag on running VMs

When getting VM disks informations on a running VM, the following error
occured:

    The minion function caused an exception: Traceback (most recent call last):
      File "/usr/lib/python3.6/site-packages/salt/minion.py", line 1673, in _thread_return
        return_data = minion_instance.executors[fname](opts, data, func, args, kwargs)
      File "/usr/lib/python3.6/site-packages/salt/executors/direct_call.py", line 12, in execute
        return func(*args, **kwargs)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2411, in full_info
        'vm_info': vm_info()}
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2020, in vm_info
        info[domain.name()] = _info(domain)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 2004, in _info
        'disks': _get_disks(dom),
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 465, in _get_disks
        output = _parse_qemu_img_info(qemu_output)
      File "/usr/lib/python3.6/site-packages/salt/modules/virt.py", line 287, in _parse_qemu_img_info
        raw_infos = salt.utils.json.loads(info)
      File "/usr/lib/python3.6/site-packages/salt/utils/json.py", line 92, in loads
        return json_module.loads(s, **kwargs)
      File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads
        return _default_decoder.decode(s)
      File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This is due to the fact that qemu-img can't get infos on a disk that is
already used like by a running VM. Using the qemu-img -U flag gets it
running in all cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants