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

Disk: add new dataStore element to disk.py #4052

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

meinaLi
Copy link
Contributor

@meinaLi meinaLi commented Jan 13, 2025

Now a new element dataStore has been implemented. So add it to disk.py. I also found that the "attrs" has included the "dev" and "file" in "slots = ("attrs", "dev", "protocol", "name", "host", "file", "auth")" actually. So I've also updated it.

@meinaLi meinaLi marked this pull request as draft January 13, 2025 06:32
Now a new element dataStore has been implemented. So add it to disk.py. I also found that the "attrs" has included the "dev" and "file" in "slots = ("attrs", "dev", "protocol", "name", "host", "file", "auth")" actually. So I've also updated it.

Signed-off-by: Meina Li <[email protected]>
@meinaLi
Copy link
Contributor Author

meinaLi commented Jan 13, 2025

>>>from virttest.libvirt_xml.devices import disk
>>>disk_dev = disk.Disk()
>>>disk_dev.xml = """
<disk type='file' device='disk'>
    <driver name='qemu' type='qcow2'/>
    <source file='/path/to/datastore.qcow2'>
      <dataStore type='file'>
        <format type='raw'/>
        <source file='/path/to/datastore'/>
      </dataStore>
    </source>
    <backingStore type='file'>
      <format type='qcow2'/>
      <source file='/var/lib/libvirt/images/base-with-data-file.qcow'>
        <dataStore type='block'>
          <format type='raw'/>
          <source dev='/dev/mapper/base2'/>
        </dataStore>
      </source>
    </backingStore>
    <target dev='vdh' bus='virtio'/>
  </disk>
  """
>>>disk_dev.fetch_attrs()
{'target': {'dev': 'vdh', 'bus': 'virtio'},
 'source': {'attrs': {'file': '/path/to/datastore.qcow2'},
  'dataStore': {'source': {'attrs': {'file': '/path/to/datastore'}},
   'type': 'file',
   'format': {'type': 'raw'}}},
 'driver': {'name': 'qemu', 'type': 'qcow2'},
 'device': 'disk',
 'type_name': 'file',
 'backingstore': {'source': {'datastore': {'source': {'attrs': {'dev': '/dev/mapper/base2'}},
    'type': 'block',
    'format': {'type': 'raw'}},
   'attrs': {'file': '/var/lib/libvirt/images/base-with-data-file.qcow'}},
  'type': 'file',
  'format': {'type': 'qcow2'}}}

@meinaLi meinaLi marked this pull request as ready for review January 14, 2025 07:01
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.

1 participant