[virt-tools-list] [PATCH] Error out cleanly when autoclone or destination file is not specified

Madhu Pavan kmp at linux.vnet.ibm.com
Sat Aug 20 03:42:55 UTC 2016



On 08/19/2016 08:48 PM, Cole Robinson wrote:
> On 08/19/2016 03:53 AM, Kothapally Madhu Pavan wrote:
>> When virt-clone is used without autoclone or destination file, libvirt
>> errors with message "ERROR    missing source information for device vda".
>> This doesn't convey what is missing. This patch will indicate which
>> options to use.
>>
> Thanks for the patch. Can you give an example XML desc and command line that
> triggers the error?
[root at ltcjuno01-vm2 virt-manager]# virt-clone --original test --name 
test-clone
ERROR    missing source information for device sda
[root at ltcjuno01-vm2 virt-manager]# virt-clone --original test --name 
test-clone --print-xml
<domain type="kvm">
   <name>test-clone</name>
   <uuid>0b6dd541-4a98-4107-9903-7f459891833f</uuid>
   <memory unit="KiB">1048576</memory>
   <currentMemory unit="KiB">1048576</currentMemory>
   <vcpu placement="static">1</vcpu>
   <os>
     <type arch="ppc64le" machine="pseries-2.4">hvm</type>
     <boot dev="hd"/>
   </os>
   <features>
     <acpi/>
     <apic/>
   </features>
   <clock offset="utc"/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
   <on_crash>restart</on_crash>
   <devices>
     <emulator>/usr/bin/qemu-kvm</emulator>
     <disk type="file" device="disk">
       <driver name="qemu" type="qcow2"/>
       <target dev="sda" bus="scsi"/>
       <address type="drive" controller="0" bus="0" target="0" unit="0"/>
     </disk>
     <controller type="usb" index="0">
       <address type="pci" domain="0x0000" bus="0x00" slot="0x02" 
function="0x0"/>
     </controller>
     <controller type="pci" index="0" model="pci-root"/>
     <controller type="scsi" index="0">
       <address type="spapr-vio" reg="0x2000"/>
     </controller>
     <interface type="network">
       <mac address="52:54:00:17:74:f3"/>
       <source network="default"/>
       <model type="rtl8139"/>
       <address type="pci" domain="0x0000" bus="0x00" slot="0x01" 
function="0x0"/>
     </interface>
     <serial type="pty">
       <target port="0"/>
       <address type="spapr-vio" reg="0x30000000"/>
     </serial>
     <console type="pty">
       <target type="serial" port="0"/>
       <address type="spapr-vio" reg="0x30000000"/>
     </console>
     <memballoon model="virtio">
       <address type="pci" domain="0x0000" bus="0x00" slot="0x03" 
function="0x0"/>
     </memballoon>
     <panic model="pseries"/>
   </devices>
</domain>

Thanks,
Madhu Pavan.
> Actually I think the best thing to do is make --auto-clone the default, unless
> a --file is specified. It should have always worked like that IMO but
> --auto-clone is slightly newer than the tool itself
>
> - Cole
>
>> Signed-off-by: Kothapally Madhu Pavan <kmp at linux.vnet.ibm.com>
>> ---
>>   tests/clitest.py |    4 ++--
>>   virt-clone       |    7 ++++++-
>>   2 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/tests/clitest.py b/tests/clitest.py
>> index 4bcd85c..8009082 100644
>> --- a/tests/clitest.py
>> +++ b/tests/clitest.py
>> @@ -930,7 +930,7 @@ c.add_invalid("-o test-clone-simple -n newvm --file %(EXISTIMG1)s --clone-runnin
>>   
>>   
>>   c = vclon.add_category("general", "-n clonetest")
>> -c.add_valid("-o test")  # Nodisk guest
>> +c.add_valid("-o test --auto-clone")  # Auto flag, no storage
>>   c.add_valid("-o test --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s")  # Nodisk, but with spurious files passed
>>   c.add_valid("-o test --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --prompt")  # Working scenario w/ prompt shouldn't ask anything
>>   c.add_valid("--original-xml %(CLONE_DISK_XML)s --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s")  # XML File with 2 disks
>> @@ -939,7 +939,7 @@ c.add_valid("--original-xml %(CLONE_DISK_XML)s --file %(NEWCLONEIMG1)s --file %(
>>   c.add_valid("--original-xml %(CLONE_DISK_XML)s --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --force-copy=fda")  # XML w/ disks, force copy a target with no media
>>   c.add_valid("--original-xml %(CLONE_STORAGE_XML)s --file %(MANAGEDNEW1)s")  # XML w/ managed storage, specify managed path
>>   c.add_valid("--original-xml %(CLONE_NOEXIST_XML)s --file %(EXISTIMG1)s --preserve")  # XML w/ managed storage, specify managed path across pools# Libvirt test driver doesn't support cloning across pools# XML w/ non-existent storage, with --preserve
>> -c.add_valid("-o test -n test-for-clone --replace")  # Overwriting existing VM
>> +c.add_valid("-o test -n test-for-clone --auto-clone --replace")  # Overwriting existing VM
>>   c.add_invalid("-o test foobar")  # Positional arguments error
>>   c.add_invalid("-o idontexist")  # Non-existent vm name
>>   c.add_invalid("-o idontexist --auto-clone")  # Non-existent vm name with auto flag,
>> diff --git a/virt-clone b/virt-clone
>> index 00d0e30..b689d9a 100755
>> --- a/virt-clone
>> +++ b/virt-clone
>> @@ -112,7 +112,7 @@ def parse_args():
>>                              "The status must be shut off or paused."))
>>       geng.add_argument("--original-xml",
>>                       help=_("XML file to use as the original guest."))
>> -    geng.add_argument("--auto-clone", action="store_true",
>> +    geng.add_argument("--auto-clone", dest="auto_clone", action="store_true",
>>                       help=_("Auto generate clone name and storage paths from"
>>                              " the original guest configuration."))
>>       geng.add_argument("-n", "--name", dest="new_name",
>> @@ -168,6 +168,11 @@ def main(conn=None):
>>       if conn is None:
>>           conn = cli.getConnection(options.connect)
>>   
>> +    if (options.new_diskfile is None and options.auto_clone is False and
>> +        options.xmlonly is False):
>> +        fail(_("Either --auto-clone or --file is required,"
>> +             " use '--auto-clone or --file' and try again."))
>> +
>>       design = Cloner(conn)
>>   
>>       design.clone_running = options.clone_running
>>
>> _______________________________________________
>> virt-tools-list mailing list
>> virt-tools-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/virt-tools-list
>>




More information about the virt-tools-list mailing list