virt-convert: Reimplement it

We totally break CLI compat here, but the previous tool wasn't sustainable.
Instead, repurpose the tool as strictly converting external formats
like ovf/vmx to native libvirt XML, and launch the guest.

So we drop vmx/virt-image output, and virt-image input, and a slew of
command line options. I don't think anyone was depending on this in a
scripted fashion, so in practice I don't think anyone will care.

Add much more comprehensive unit tests while we are at it.
This commit is contained in:
Cole Robinson 2014-02-05 19:09:26 -05:00
parent 2ffd5a66e6
commit 0b4a72fd77
134 changed files with 2114 additions and 2347 deletions

View File

@ -2,36 +2,29 @@
=head1 NAME
virt-convert - convert virtual machines between formats
virt-convert - convert ovf/vmx to native libvirt guests
=head1 SYNOPSIS
B<virt-convert> [OPTION]... INPUT.VMX|INPUT-DIR [OUTPUT.XML|OUTPUT-DIR]
B<virt-convert> INPUT.vmx|INPUT.ovf|INPUT-DIR|INPUT.zip [OPTIONS]
=head1 DESCRIPTION
B<virt-convert> is a command line tool for converting virtual machines
from one format to another. Pass in either a VM definition file (such
as VMWare vmx format) or a directory containing a VM. By default, a new
VM definition file, and converted disk images, will be placed in a new
output directory.
B<virt-convert> is a command line tool for converting VMX of OVF virtual
machines to native libvirt XML. Disk format conversion can also be done
at the same time.
If an output directory is specified, it will be created if necessary,
and the output VM definition placed within, along with any disk images
as needed.
The simplest invocation is simply: virt-convert INPUT. INPUT might be
a .vmx or .ovf file, a directory containing a .vmx or .ovf file (and
likely 1 or more disk images), or an appliance archive like .zip, .tar.gz,
or .ova. virt-convert will try to do the right thing in each case.
If an output VM definition file is specified, it will be created
alongside any disks in the same directory.
By default, the virt-convert will convert all encountered disk images
to 'raw' format, sending the output to a new directory location. So the
original disk images are _not_ altered in place.
=head1 OPTIONS
Any of the options can be omitted, in which case B<virt-convert> will
use defaults when required. An input VM definition or containing directory
must be provided. By default, an output directory is generated based upon
the name of the VM. The default input format is VMWare vmx, and the
default output format is a libvirt "image" XML definition
(see L<virt-image(5)>).
=over 4
=item -h, --help
@ -42,62 +35,27 @@ Show the help message and exit
Show program's version number and exit
=item --connect=URI
Connect to a non-default hypervisor. See L<virt-install(1)> for details
=back
=head2 Conversion Options
=over 2
=item -i format
=item -i/--input-format FORMAT
Input format. Currently, C<vmx>, C<virt-image>, and C<ovf> are supported.
Input format. This should be auto-detected, but can be forced if necessary. Currently C<vmx> and C<ovf> are supported.
=item -o format
=item -D/--disk-format DISK-FORMAT
Output format. Currently, C<vmx> and C<virt-image> are supported.
Output disk format. The default is 'raw', so any encountered disk images will be converted to 'raw' format using L<qemu-img(1)>. Pass C<none> if no conversion should be performed: in this case the images will just be copied to the specified --destination.
=item -D format
=item --destination DIRECTORY
Output disk format, or C<none> if no conversion should be performed. See
L<qemu-img(1)>.
=back
=head2 Virtualization Type options
Options to override the default virtualization type choices.
=over 2
=item -v, --hvm Create a fully virtualized guest image
Convert machine to a hvm/qemu based image (this is the default if paravirt
is not specified)
=item -p, --paravirt Create a paravirtualized guest image
Convert machine to a paravirt xen based image
=back
=head2 General Options
General configuration parameters that apply to all types of guest installs.
=over 2
=item -a ARCH, --arch=ARCH
Architecture of the virtual machine (i686, x86_64, ppc). Defaults to
that of the host machine.
=item --os-variant=OS_VARIANT
Optimize the guest configuration for a specific operating system (ex.
'fedora18', 'rhel7', 'winxp'). While not requires, specifying this
options is HIGHLY RECOMMENDED, as it can greatly increase performance
by specifying virtio among other guest tweaks.
See L<virt-install(1)> for valid values.
The directory to send converted/copied disk images. If not specified, the hypervisor default is used, typically /var/lib/libvirt/images.
=back
@ -105,6 +63,23 @@ See L<virt-install(1)> for valid values.
=over 2
=item --noautoconsole
Don't automatically try to connect to the guest console. The default behaviour
is to launch L<virt-viewer(1)> to display the graphical console, or to run the
C<virsh> C<console> command to display the text console. Use of this parameter
will disable this behaviour.
=item --print-xml
Print the generated libvirt XML, but do not perform any disk conversions or
install/start the guest. This option implies --dry-run.
=item --dry-run
Proceed through the conversion process, but don't convert disks or actually
write any converted files.
=item -q, --quiet
Avoid verbose output.
@ -113,22 +88,21 @@ Avoid verbose output.
Print debugging information
=item --dry-run
Proceed through the conversion process, but don't convert disks or actually
write any converted files.
=back
=head1 EXAMPLES
Convert a paravirt guest from C<image.vmx>:
Run a fedora18 OVA archive:
# virt-convert --arch=i686 --paravirt image.vmx
# virt-convert fedora18.ova
Convert a 64-bit hvm guest:
Run an extracted zip archive containing a centos6 .vmx and .vmdk file, converting the images to qcow2 format
# virt-convert --arch=x86_64 vmx-appliance/ hvm-appliance/
# virt-convert centos6/ --disk-format qcow2
Convert the specified .vmx file. Any references disk images must be in the same directory. Don't change the disk format. Move the disk images to /tmp
# virt-convert foo.vmx --disk-format none --destination /tmp
=head1 BUGS
@ -143,7 +117,7 @@ There is NO WARRANTY, to the extent permitted by law.
=head1 SEE ALSO
L<virt-image(5)>, the project website C<http://virt-manager.org>
L<virt-install(1)>, the project website C<http://virt-manager.org>
=cut

View File

@ -827,7 +827,7 @@ This deprecates the following options: --vnc, --vncport, --vnclisten, -k/--keyma
=item --noautoconsole
Don't automatically try to connect to the guest console. The default behaviour
is to launch a VNC client to display the graphical console, or to run the
is to launch L<virt-viewer(1)> to display the graphical console, or to run the
C<virsh> C<console> command to display the text console. Use of this parameter
will disable this behaviour.

View File

@ -1,5 +0,0 @@
Generating output in 'virt-image' format to /tmp/__virtinst_tests__virtconv-outdir/
Converting disk 'root.raw' to type raw...
Converting disk 'scratch.raw' to type raw...
Converting disk 'data.raw' to type raw...
Done.

View File

@ -0,0 +1,69 @@
Copying test.ovf-disk1.vmdk to /tmp/test.ovf-disk1
Copying testfile to /tmp/testfile
<domain type="qemu">
<name>test.ovf</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<description>This is the description, created by RWMJ.</description>
<memory>795648</memory>
<currentMemory>795648</currentMemory>
<vcpu>3</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu"/>
<source file="/tmp/test.ovf-disk1"/>
<target dev="sda" bus="scsi"/>
</disk>
<disk type="file" device="disk">
<driver name="qemu"/>
<source file="/tmp/testfile"/>
<target dev="hda" bus="ide"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>

View File

@ -0,0 +1,65 @@
Running /usr/bin/qemu-img convert -O qcow2 fedora.vmdk /var/lib/libvirt/images/fedora.qcow2
<domain type="qemu">
<name>fedora</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="/var/lib/libvirt/images/fedora.qcow2"/>
<target dev="sda" bus="scsi"/>
</disk>
<disk type="block" device="cdrom">
<target dev="hda" bus="ide"/>
<readonly/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated by VMware VirtualCenter Server, User: jmh, UTC time: 2009-07-08T12:17:47.265625Z -->
<Envelope vmw:buildId="build-162856" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<References>
<File ovf:href="test.ovf-disk1.vmdk" ovf:id="file1" ovf:size="953269760" />
<File ovf:href="testfile" ovf:id="vmfile1" ovf:size="1234" />
</References>
<DiskSection>
<Info>Virtual disk information</Info>
<Disk ovf:capacity="8" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" />
</DiskSection>
<NetworkSection>
<Info>The list of logical networks</Info>
<Network ovf:name="VM Network">
<Description>The VM Network network</Description>
</Network>
</NetworkSection>
<VirtualSystem ovf:id="test.ovf">
<Info>A virtual machine</Info>
<Name>test.ovf</Name>
<OperatingSystemSection ovf:id="80" ovf:version="5" vmw:osType="rhel5_64Guest">
<Info>The kind of installed guest operating system</Info>
<Description>Red Hat Enterprise Linux 5 (64-bit)</Description>
</OperatingSystemSection>
<VirtualHardwareSection>
<Info>Virtual hardware requirements</Info>
<System>
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
<vssd:InstanceID>0</vssd:InstanceID>
<vssd:VirtualSystemIdentifier>test.ovf</vssd:VirtualSystemIdentifier>
<vssd:VirtualSystemType>vmx-07</vssd:VirtualSystemType>
</System>
<Item>
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>1</rasd:InstanceID>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>3</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:Description>Memory Size</rasd:Description>
<rasd:ElementName>512MB of memory</rasd:ElementName>
<rasd:InstanceID>2</rasd:InstanceID>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:VirtualQuantity>777</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>SCSI Controller</rasd:Description>
<rasd:ElementName>SCSI controller 0</rasd:ElementName>
<rasd:InstanceID>3</rasd:InstanceID>
<rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
<rasd:ResourceType>6</rasd:ResourceType>
</Item>
<Item>
<rasd:Address>1</rasd:Address>
<rasd:Description>IDE Controller</rasd:Description>
<rasd:ElementName>IDE 1</rasd:ElementName>
<rasd:InstanceID>4</rasd:InstanceID>
<rasd:ResourceType>5</rasd:ResourceType>
</Item>
<Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>IDE Controller</rasd:Description>
<rasd:ElementName>IDE 0</rasd:ElementName>
<rasd:InstanceID>5</rasd:InstanceID>
<rasd:ResourceType>5</rasd:ResourceType>
</Item>
<Item ovf:required="false">
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:Description>Floppy Drive</rasd:Description>
<rasd:ElementName>Floppy drive 1</rasd:ElementName>
<rasd:InstanceID>6</rasd:InstanceID>
<rasd:ResourceType>14</rasd:ResourceType>
</Item>
<Item ovf:required="false">
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:ElementName>CD/DVD Drive 1</rasd:ElementName>
<rasd:InstanceID>7</rasd:InstanceID>
<rasd:Parent>4</rasd:Parent>
<rasd:ResourceType>15</rasd:ResourceType>
</Item>
<Item>
<rasd:AddressOnParent>7</rasd:AddressOnParent>
<rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
<rasd:Connection>VM Network</rasd:Connection>
<rasd:Description>E1000 ethernet adapter on "VM Network"</rasd:Description>
<rasd:ElementName>Network adapter 1</rasd:ElementName>
<rasd:InstanceID>8</rasd:InstanceID>
<rasd:ResourceSubType>E1000</rasd:ResourceSubType>
<rasd:ResourceType>10</rasd:ResourceType>
</Item>
<Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:ElementName>Hard disk 1</rasd:ElementName>
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
<rasd:InstanceID>9</rasd:InstanceID>
<rasd:Parent>3</rasd:Parent>
<rasd:ResourceType>17</rasd:ResourceType>
</Item>
<Item>
<rasd:AddressOnParent>1</rasd:AddressOnParent>
<rasd:ElementName>Hard disk 2</rasd:ElementName>
<rasd:HostResource>ovf:/file/vmfile1</rasd:HostResource>
<rasd:InstanceID>10</rasd:InstanceID>
<rasd:Parent>4</rasd:Parent>
<rasd:ResourceType>17</rasd:ResourceType>
</Item>
</VirtualHardwareSection>
<AnnotationSection ovf:required="false">
<Info>A human-readable annotation</Info>
<Annotation>This is the description, created by RWMJ.</Annotation>
</AnnotationSection>
</VirtualSystem>
<TestSection ovf:required="false">
<Info>A human-readable annotation</Info>
<Annotation>This is the description, created by RWMJ.</Annotation>
</TestSection>
</Envelope>

View File

@ -1,48 +0,0 @@
<image>
<name>test-image</name>
<label>A simple test image</label>
<domain>
<boot type='xen'>
<guest>
<os_type>xen</os_type>
<arch>i386</arch>
<features><pae/></features>
</guest>
<os>
<loader>pygrub</loader>
</os>
<drive disk="root.raw" target="xvda"/>
<drive disk="data.raw" target="xvdb"/>
<drive disk="scratch.raw" target="xvdc"/>
</boot>
<boot type="hvm">
<guest>
<arch>i686</arch>
<features><pae/></features>
</guest>
<os>
<type>hvm</type>
<loader dev="hd"/>
</os>
<drive disk="root.raw" target="hda"/>
<drive disk="data.raw" target="hdb"/>
<drive disk="scratch.raw" target="hdd"/>
</boot>
<devices>
<vcpu>7</vcpu>
<memory>262144</memory>
<interface/>
<graphics/>
</devices>
</domain>
<storage>
<disk file="disk.img"/>
<disk size="4096" use="system">
<partition file="boot.img"/>
<partition file="root.img"/>
</disk>
<disk file="root.raw" format="raw" size="4096" use="system"/>
<disk file="data.raw" format="raw" size='2048' use="data"/>
<disk file="scratch.raw" format="raw" size='100' use='scratch'/>
</storage>
</image>

View File

@ -32,7 +32,6 @@ from virtinst import support
from tests import virtinstall, virtimage, virtclone, virtconvert, virtxml
from tests import utils
os.environ["VIRTCONV_TEST_NO_DISK_CONVERSION"] = "1"
os.environ["LANG"] = "en_US.UTF-8"
# Used to ensure consistent SDL xml output
@ -75,13 +74,10 @@ virtimage_exist = ["/tmp/__virtinst__cli_root.raw"]
# Images created by virt-image
virtimage_new = ["/tmp/__virtinst__cli_scratch.raw"]
# virt-convert output dirs
virtconv_dirs = [virtconv_out]
exist_files = exist_images + virtimage_exist
new_files = new_images + virtimage_new + virtconv_dirs
new_files = new_images + virtimage_new
clean_files = (new_images + exist_images +
virtimage_exist + virtimage_new + virtconv_dirs + [ro_dir])
virtimage_exist + virtimage_new + [ro_dir])
promptlist = []
@ -118,10 +114,8 @@ test_files = {
'COLLIDE' : "/dev/default-pool/collidevol1.img",
'SHARE' : "/dev/default-pool/sharevol.img",
'VIRTCONV_OUT' : "%s/test.out" % virtconv_out,
'VC_IMG1' : "%s/virtimage/test1.virt-image" % vcdir,
'VC_IMG2' : "tests/image-xml/image-format.xml",
'VMX_IMG1' : "%s/vmx/test1.vmx" % vcdir,
'OVF_IMG1' : "%s/tests/virtconv-files/ovf_input/test1.ovf" % os.getcwd(),
'VMX_IMG1' : "%s/tests/virtconv-files/vmx_input/test1.vmx" % os.getcwd(),
}
@ -173,9 +167,9 @@ class Command(object):
elif app.count("virt-image"):
ret = virtimage.main(conn=conn)
elif app.count("virt-convert"):
ret = virtconvert.main()
ret = virtconvert.main(conn=conn)
elif app.count("virt-xml"):
ret = virtxml.main()
ret = virtxml.main(conn=conn)
except SystemExit, sys_e:
ret = sys_e.code
@ -226,7 +220,7 @@ class Command(object):
conn = utils.openconn(self.argv[idx + 1])
break
if not conn and "virt-convert" not in self.argv[0]:
if not conn:
raise RuntimeError("couldn't parse URI from command %s" %
self.argv)
@ -380,9 +374,8 @@ class App(object):
if not iscompare:
args = "--debug"
if self.appname != "virt-convert":
if "--connect " not in cli:
args += " --connect %(TESTURI)s"
if "--connect " not in cli:
args += " --connect %(TESTURI)s"
if self.appname in ["virt-install"]:
if "--name " not in cli:
@ -426,6 +419,7 @@ class App(object):
cmd = Command(cmdstr)
cmd.check_success = valid
if compfile:
compfile = os.path.basename(self.appname) + "-" + compfile
cmd.compare_file = "%s/%s.xml" % (compare_xmldir, compfile)
cmd.skip_check = skip_check or category.skip_check
cmd.compare_check = compare_check or category.compare_check
@ -784,76 +778,75 @@ c.add_invalid("test-many-devices --add-device --host-device 0x0781:0x5151 --upda
c.add_invalid("test-many-devices --remove-device --host-device 1 --update") # test driver doesn't support detachdevice...
c.add_invalid("test-many-devices --edit --graphics password=foo --update") # test driver doesn't support updatdevice...
c.add_invalid("--build-xml --memory 10,maxmemory=20") # building XML for option that doesn't support it
c.add_compare("test --print-xml --edit --vcpus 7", "virtxml-print-xml") # test --print-xml
c.add_compare("test --print-xml --edit --vcpus 7", "virtxml-print-xml") # test --print-xml
c.add_compare("--edit --cpu host-passthrough", "virtxml-stdin-edit", input_file=(xmldir + "/virtxml-stdin-edit.xml")) # stdin test
c.add_compare("--build-xml --cpu pentium3,+x2apic", "virtxml-build-cpu")
c.add_compare("--build-xml --tpm /dev/tpm", "virtxml-build-tpm")
c.add_compare("--build-xml --blkiotune weight=100,device_path=/dev/sdf,device_weight=200", "virtxml-build-blkiotune")
c.add_compare("test --print-xml --edit --vcpus 7", "print-xml") # test --print-xml
c.add_compare("--edit --cpu host-passthrough", "stdin-edit", input_file=(xmldir + "/virtxml-stdin-edit.xml")) # stdin test
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 --blkiotune weight=100,device_path=/dev/sdf,device_weight=200", "build-blkiotune")
c = vixml.add_category("simple edit diff", "test-many-devices --edit --print-diff --define", compare_check=support.SUPPORT_CONN_PANIC_DEVICE)
c.add_compare("""--metadata name=foo-my-new-name,uuid=12345678-12F4-1234-1234-123456789AFA,description="hey this is my
new
very,very=new desc\\\'",title="This is my,funky=new title" """, "virtxml-edit-simple-metadata")
c.add_compare("--memory 500,maxmemory=1000,hugepages=off", "virtxml-edit-simple-memory")
c.add_compare("--vcpus 10,maxvcpus=20,cores=5,sockets=4,threads=1", "virtxml-edit-simple-vcpus")
c.add_compare("--cpu model=pentium2,+x2apic,forbid=pbe", "virtxml-edit-simple-cpu")
c.add_compare("--numatune 1-5,7,mode=strict", "virtxml-edit-simple-numatune")
c.add_compare("--blkiotune weight=500,device_path=/dev/sdf,device_weight=600", "virtxml-edit-simple-blkiotune")
c.add_compare("--boot loader=foo.bar,network,useserial=on,init=/bin/bash", "virtxml-edit-simple-boot")
c.add_compare("--security label=foo,bar,baz,UNKNOWN=val,relabel=on", "virtxml-edit-simple-security")
c.add_compare("--features eoi=on,hyperv_relaxed=off,acpi=", "virtxml-edit-simple-features")
c.add_compare("--clock offset=localtime,hpet_present=yes,kvmclock_present=no,rtc_tickpolicy=merge", "virtxml-edit-simple-clock")
c.add_compare("--pm suspend_to_mem=yes,suspend_to_disk=no", "virtxml-edit-simple-pm")
c.add_compare("--disk /dev/zero,perms=ro,startup_policy=optional", "virtxml-edit-simple-disk")
c.add_compare("--disk path=", "virtxml-edit-simple-disk-remove-path")
c.add_compare("--network source=br0,type=bridge,model=virtio,mac=", "virtxml-edit-simple-network")
c.add_compare("--graphics tlsport=5902,keymap=ja", "virtxml-edit-simple-graphics")
c.add_compare("--controller index=2,model=lsilogic", "virtxml-edit-simple-controller")
c.add_compare("--smartcard type=spicevmc", "virtxml-edit-simple-smartcard")
c.add_compare("--redirdev type=spicevmc,server=example.com:12345", "virtxml-edit-simple-redirdev")
c.add_compare("--tpm path=/dev/tpm", "virtxml-edit-simple-tpm")
c.add_compare("--rng rate_bytes=3333,rate_period=4444", "virtxml-edit-simple-rng")
c.add_compare("--watchdog action=reset", "virtxml-edit-simple-watchdog")
c.add_compare("--memballoon model=none", "virtxml-edit-simple-memballoon")
c.add_compare("--serial pty", "virtxml-edit-simple-serial")
c.add_compare("--parallel unix,path=/some/other/log", "virtxml-edit-simple-parallel")
c.add_compare("--channel null", "virtxml-edit-simple-channel")
c.add_compare("--console target_type=serial", "virtxml-edit-simple-console")
c.add_compare("--filesystem /1/2/3,/4/5/6,mode=mapped", "virtxml-edit-simple-filesystem")
c.add_compare("--video cirrus", "virtxml-edit-simple-video")
c.add_compare("--sound pcspk", "virtxml-edit-simple-soundhw")
c.add_compare("--host-device 0x0781:0x5151,driver_name=vfio", "virtxml-edit-simple-host-device")
very,very=new desc\\\'",title="This is my,funky=new title" """, "edit-simple-metadata")
c.add_compare("--memory 500,maxmemory=1000,hugepages=off", "edit-simple-memory")
c.add_compare("--vcpus 10,maxvcpus=20,cores=5,sockets=4,threads=1", "edit-simple-vcpus")
c.add_compare("--cpu model=pentium2,+x2apic,forbid=pbe", "edit-simple-cpu")
c.add_compare("--numatune 1-5,7,mode=strict", "edit-simple-numatune")
c.add_compare("--blkiotune weight=500,device_path=/dev/sdf,device_weight=600", "edit-simple-blkiotune")
c.add_compare("--boot loader=foo.bar,network,useserial=on,init=/bin/bash", "edit-simple-boot")
c.add_compare("--security label=foo,bar,baz,UNKNOWN=val,relabel=on", "edit-simple-security")
c.add_compare("--features eoi=on,hyperv_relaxed=off,acpi=", "edit-simple-features")
c.add_compare("--clock offset=localtime,hpet_present=yes,kvmclock_present=no,rtc_tickpolicy=merge", "edit-simple-clock")
c.add_compare("--pm suspend_to_mem=yes,suspend_to_disk=no", "edit-simple-pm")
c.add_compare("--disk /dev/zero,perms=ro,startup_policy=optional", "edit-simple-disk")
c.add_compare("--disk path=", "edit-simple-disk-remove-path")
c.add_compare("--network source=br0,type=bridge,model=virtio,mac=", "edit-simple-network")
c.add_compare("--graphics tlsport=5902,keymap=ja", "edit-simple-graphics")
c.add_compare("--controller index=2,model=lsilogic", "edit-simple-controller")
c.add_compare("--smartcard type=spicevmc", "edit-simple-smartcard")
c.add_compare("--redirdev type=spicevmc,server=example.com:12345", "edit-simple-redirdev")
c.add_compare("--tpm path=/dev/tpm", "edit-simple-tpm")
c.add_compare("--rng rate_bytes=3333,rate_period=4444", "edit-simple-rng")
c.add_compare("--watchdog action=reset", "edit-simple-watchdog")
c.add_compare("--memballoon model=none", "edit-simple-memballoon")
c.add_compare("--serial pty", "edit-simple-serial")
c.add_compare("--parallel unix,path=/some/other/log", "edit-simple-parallel")
c.add_compare("--channel null", "edit-simple-channel")
c.add_compare("--console target_type=serial", "edit-simple-console")
c.add_compare("--filesystem /1/2/3,/4/5/6,mode=mapped", "edit-simple-filesystem")
c.add_compare("--video cirrus", "edit-simple-video")
c.add_compare("--sound pcspk", "edit-simple-soundhw")
c.add_compare("--host-device 0x0781:0x5151,driver_name=vfio", "edit-simple-host-device")
c = vixml.add_category("edit selection", "test-many-devices --print-diff --define", compare_check=support.SUPPORT_CONN_PANIC_DEVICE)
c.add_invalid("--edit target=vvv --disk /dev/null") # no match found
c.add_compare("--edit 3 --sound pcspk", "virtxml-edit-pos-num")
c.add_compare("--edit -1 --video qxl", "virtxml-edit-neg-num")
c.add_compare("--edit all --host-device driver_name=vfio", "virtxml-edit-all")
c.add_compare("--edit ich6 --sound pcspk", "virtxml-edit-select-sound-model")
c.add_compare("--edit target=hda --disk /dev/null", "virtxml-edit-select-disk-target")
c.add_compare("--edit /tmp/foobar2 --disk shareable=off,readonly=on", "virtxml-edit-select-disk-path")
c.add_compare("--edit mac=00:11:7f:33:44:55 --network target=nic55", "virtxml-edit-select-network-mac")
c.add_compare("--edit 3 --sound pcspk", "edit-pos-num")
c.add_compare("--edit -1 --video qxl", "edit-neg-num")
c.add_compare("--edit all --host-device driver_name=vfio", "edit-all")
c.add_compare("--edit ich6 --sound pcspk", "edit-select-sound-model")
c.add_compare("--edit target=hda --disk /dev/null", "edit-select-disk-target")
c.add_compare("--edit /tmp/foobar2 --disk shareable=off,readonly=on", "edit-select-disk-path")
c.add_compare("--edit mac=00:11:7f:33:44:55 --network target=nic55", "edit-select-network-mac")
c = vixml.add_category("edit clear", "test-many-devices --print-diff --define", compare_check=support.SUPPORT_CONN_PANIC_DEVICE)
c.add_invalid("--edit --memory 200,clearxml=yes") # clear isn't wired up for memory
c.add_compare("--edit --cpu host-passthrough,clearxml=yes", "virtxml-edit-clear-cpu")
c.add_compare("--edit --clock offset=utc,clearxml=yes", "virtxml-edit-clear-clock")
c.add_compare("--edit --disk /foo/bar,target=fda,bus=fdc,device=floppy,clearxml=yes", "virtxml-edit-clear-disk")
c.add_compare("--edit --cpu host-passthrough,clearxml=yes", "edit-clear-cpu")
c.add_compare("--edit --clock offset=utc,clearxml=yes", "edit-clear-clock")
c.add_compare("--edit --disk /foo/bar,target=fda,bus=fdc,device=floppy,clearxml=yes", "edit-clear-disk")
c = vixml.add_category("add/rm devices", "test-many-devices --print-diff --define", compare_check=support.SUPPORT_CONN_PANIC_DEVICE)
c.add_invalid("--add-device --security foo") # --add-device without a device
c.add_invalid("--remove-device --clock utc") # --remove-device without a dev
c.add_compare("--add-device --host-device net_00_1c_25_10_b1_e4", "virtxml-add-host-device")
c.add_compare("--add-device --sound pcspk", "virtxml-add-sound")
c.add_compare("--add-device --disk %(EXISTIMG1)s,bus=virtio,target=vdf", "virtxml-add-disk-basic")
c.add_compare("--add-device --disk %(EXISTIMG1)s", "virtxml-add-disk-notarget") # filling in acceptable target
c.add_compare("--add-device --disk %(NEWIMG1)s,size=.01", "virtxml-add-disk-create-storage")
c.add_compare("--remove-device --sound ich6", "virtxml-remove-sound-model")
c.add_compare("--remove-device --disk 6", "virtxml-remove-disk-index")
c.add_compare("--remove-device --disk /dev/null", "virtxml-remove-disk-path")
c.add_compare("--remove-device --video all", "virtxml-remove-video-all")
c.add_compare("--add-device --host-device net_00_1c_25_10_b1_e4", "add-host-device")
c.add_compare("--add-device --sound pcspk", "add-sound")
c.add_compare("--add-device --disk %(EXISTIMG1)s,bus=virtio,target=vdf", "add-disk-basic")
c.add_compare("--add-device --disk %(EXISTIMG1)s", "add-disk-notarget") # filling in acceptable target
c.add_compare("--add-device --disk %(NEWIMG1)s,size=.01", "add-disk-create-storage")
c.add_compare("--remove-device --sound ich6", "remove-sound-model")
c.add_compare("--remove-device --disk 6", "remove-disk-index")
c.add_compare("--remove-device --disk /dev/null", "remove-disk-path")
c.add_compare("--remove-device --video all", "remove-video-all")
vimag = App("virt-image")
@ -895,18 +888,12 @@ c.add_invalid("--boot 10") # Out of bounds index
vconv = App("virt-convert")
c = vconv.add_category("misc", "")
c.add_compare("%(VC_IMG1)s %(VIRTCONV_OUT)s", "convert-default") # virt-image to default (virt-image) w/ no convert
c.add_valid("%(VC_IMG1)s -D none %(VIRTCONV_OUT)s") # virt-image to default (virt-image) w/ no convert
c.add_valid("%(VC_IMG1)s -o virt-image -D none %(VIRTCONV_OUT)s") # virt-image to virt-image w/ no convert
c.add_valid("%(VC_IMG1)s -o vmx -D none %(VIRTCONV_OUT)s") # virt-image to vmx w/ no convert
c.add_valid("%(VC_IMG1)s -o vmx -D raw %(VIRTCONV_OUT)s") # virt-image to vmx w/ raw
c.add_valid("%(VC_IMG1)s -o vmx -D vmdk %(VIRTCONV_OUT)s") # virt-image to vmx w/ vmdk
c.add_valid("%(VC_IMG1)s -o vmx -D qcow2 %(VIRTCONV_OUT)s") # virt-image to vmx w/ qcow2
c.add_valid("%(VMX_IMG1)s -o vmx -D none %(VIRTCONV_OUT)s") # vmx to vmx no convert
c.add_valid("%(VC_IMG2)s -o vmx -D vmdk %(VIRTCONV_OUT)s") # virt-image with exotic formats specified
c.add_invalid("%(VC_IMG1)s -o virt-image -D foobarfmt %(VIRTCONV_OUT)s") # virt-image to virt-image with invalid format
c.add_invalid("%(VC_IMG1)s -o ovf %(VIRTCONV_OUT)s") # virt-image to ovf (has no output formatter)
c = vconv.add_category("misc", "--connect %(KVMURI)s --dry")
c.add_invalid("%(VMX_IMG1)s --input-format foo") # invalid input format
c.add_invalid("%(EXISTIMG1)s") # invalid input file
c.add_compare("%(VMX_IMG1)s --disk-format qcow2 --print-xml", "vmx-compare")
c.add_compare("%(OVF_IMG1)s --disk-format none --destination /tmp --print-xml", "ovf-compare")

View File

@ -0,0 +1,64 @@
<domain type="qemu">
<name>CentOS-6.4-i386-Gnome.ovf</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu"/>
<source file="/var/lib/libvirt/images/CentOS-6.4-i386-Gnome-disk1"/>
<target dev="hda" bus="ide"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>
Copying CentOS-6.4-i386-Gnome-disk1.vmdk to /var/lib/libvirt/images/CentOS-6.4-i386-Gnome-disk1

View File

@ -0,0 +1,71 @@
<domain type="qemu">
<name>test.ovf</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<description>This is the description, created by RWMJ.</description>
<memory>795648</memory>
<currentMemory>795648</currentMemory>
<vcpu>3</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu"/>
<source file="/var/lib/libvirt/images/test.ovf-disk1"/>
<target dev="sda" bus="scsi"/>
</disk>
<disk type="file" device="disk">
<driver name="qemu"/>
<source file="/var/lib/libvirt/images/testfile"/>
<target dev="hda" bus="ide"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>
Copying test.ovf-disk1.vmdk to /var/lib/libvirt/images/test.ovf-disk1
Copying testfile to /var/lib/libvirt/images/testfile

View File

@ -0,0 +1,71 @@
<domain type="qemu">
<name>test.ovf</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<description>This is the description, created by RWMJ.</description>
<memory>795648</memory>
<currentMemory>795648</currentMemory>
<vcpu>3</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="/var/lib/libvirt/images/test.ovf-disk1.qcow2"/>
<target dev="sda" bus="scsi"/>
</disk>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"/>
<source file="/var/lib/libvirt/images/testfile.qcow2"/>
<target dev="hda" bus="ide"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>
Running /usr/bin/qemu-img convert -O qcow2 test.ovf-disk1.vmdk /var/lib/libvirt/images/test.ovf-disk1.qcow2
Running /usr/bin/qemu-img convert -O qcow2 testfile /var/lib/libvirt/images/testfile.qcow2

View File

@ -0,0 +1,65 @@
<domain type="qemu">
<name>w2k3_32bit</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<description>Description added by RWMJ.</description>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu"/>
<source file="/var/lib/libvirt/images/w2k3_32bit-disk1"/>
<target dev="sda" bus="scsi"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
<model type="e1000"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>
Copying w2k3 32bit-disk1.vmdk to /var/lib/libvirt/images/w2k3_32bit-disk1

View File

@ -0,0 +1,70 @@
<domain type="qemu">
<name>minix</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>204800</memory>
<currentMemory>204800</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="x86_64">hvm</type>
<boot dev="cdrom"/>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset="utc">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type="block" device="cdrom">
<driver type="raw"/>
<target dev="hda" bus="ide"/>
<readonly/>
</disk>
<disk type="file" device="disk">
<driver name="qemu"/>
<source file="/var/lib/libvirt/images/MS-DOS"/>
<target dev="hdb" bus="ide"/>
</disk>
<controller type="usb" index="0" model="ich9-ehci1"/>
<controller type="usb" index="0" model="ich9-uhci1">
<master startport="0"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci2">
<master startport="2"/>
</controller>
<controller type="usb" index="0" model="ich9-uhci3">
<master startport="4"/>
</controller>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
</interface>
<input type="mouse" bus="ps2"/>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes"/>
<console type="pty"/>
<channel type="spicevmc">
<target type="virtio" name="com.redhat.spice.0"/>
</channel>
<sound model="ich6"/>
<video>
<model type="qxl"/>
</video>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
<redirdev bus="usb" type="spicevmc"/>
</devices>
</domain>
test-vmx-zip.zip appears to be an archive, running: unar -o /var/tmp/virt-convert-tmp test-vmx-zip.zip
Copying MS-DOS.vmdk to /var/lib/libvirt/images/MS-DOS

Some files were not shown because too many files have changed in this diff Show More