On Wed, Sep 19, 2012 at 11:49 AM, Chris Evich <[email protected]> wrote:
>
> Would someone mind checking this fix out real quick?  I think I've got it
> correct but want to make sure it works beyond my test machine.  Thanks.

Yep, your patch did need some fix:

[lmr@freedom virt]$ git diff
diff --git a/client/tests/virt/virttest/virt_vm.py
b/client/tests/virt/virttest/virt_vm.py
index f87c766..94a0521 100644
--- a/client/tests/virt/virttest/virt_vm.py
+++ b/client/tests/virt/virttest/virt_vm.py
@@ -447,12 +447,12 @@ class BaseVM(object):
             # Command-line encoded state doesn't include all params
             # TODO: Check more than just networking
             other_virtnet = utils_misc.VirtNet(params, name, self.instance)
-            if self.virtnet != other_virtnet
+            if self.virtnet != other_virtnet:
                 logging.debug("VM params in env match, but network differs, "
                               "restarting")
                 logging.debug("\t" + str(self.virtnet))
                 logging.debug("\t!=")
-                logging.debug("\t" + str(other_virtnet)
+                logging.debug("\t" + str(other_virtnet))
                 return True
             else:
                 logging.debug("VM params in env do match requested,
continuing.")

But it was all trivial stuff, I'll get the corrected version applied to next.

Thanks!

>
> On 09/19/2012 10:47 AM, Chris Evich wrote:
>>
>> + Both libvirt and KVM had nearly identical needs_restart
>> implimentations.  This patch allows them to inherit common checks while
>> allowing specialty checks via subclass overrides.
>>
>> + Fix networking bug in needs_restart() for virt-kvm and virt-libvirt.
>> Before each test, preprocess_vm() checks any VM instances stored in
>> env file against requested parameters, using vm.needs_restart().  However,
>> as implemented, only parameters encoded on the qemu or virt-install
>> command-line are tested.  This patch adds a check to also compare
>> networking
>> parameters.
>>
>> N.B. It does NOT verify non-networking related hot-added devices.
>>
>> Signed-off-by: Chris Evich<[email protected]>
>> ---
>>   client/tests/virt/virttest/kvm_vm.py     |   18 +++---------------
>>   client/tests/virt/virttest/libvirt_vm.py |   30
>> ++++++++----------------------
>>   client/tests/virt/virttest/virt_vm.py    |   27
>> +++++++++++++++++++++++++++
>>   3 files changed, 38 insertions(+), 37 deletions(-)
>>
>> diff --git a/client/tests/virt/virttest/kvm_vm.py
>> b/client/tests/virt/virttest/kvm_vm.py
>> index 078ef0f..247f0eb 100644
>> --- a/client/tests/virt/virttest/kvm_vm.py
>> +++ b/client/tests/virt/virttest/kvm_vm.py
>> @@ -157,7 +157,7 @@ class VM(virt_vm.BaseVM):
>>           return VM(name, params, root_dir, address_cache, state)
>>
>>
>> -    def __make_qemu_command(self, name=None, params=None, root_dir=None):
>> +    def make_create_command(self, name=None, params=None, root_dir=None):
>>           """
>>           Generate a qemu command line. All parameters are optional. If a
>>           parameter is not supplied, the corresponding value stored in the
>> @@ -1490,7 +1490,7 @@ class VM(virt_vm.BaseVM):
>>               # Generate basic parameter values for all NICs and create
>> TAP fd
>>               for nic in self.virtnet:
>>                   # fill in key values, validate nettype
>> -                # note: __make_qemu_command() calls vm.add_nic (i.e. on a
>> copy)
>> +                # note: make_create_command() calls vm.add_nic (i.e. on a
>> copy)
>>                   nic = self.add_nic(**dict(nic)) # implied add_netdev
>>                   if mac_source:
>>                       # Will raise exception if source doesn't
>> @@ -1580,7 +1580,7 @@ class VM(virt_vm.BaseVM):
>>                       raise virt_vm.VMPAError(pa_type)
>>
>>               # Make qemu command
>> -            qemu_command = self.__make_qemu_command()
>> +            qemu_command = self.make_create_command()
>>
>>               # Add migration parameters if required
>>               if migration_mode == "tcp":
>> @@ -2624,18 +2624,6 @@ class VM(virt_vm.BaseVM):
>>                       migration_exec_cmd="cat "+path, mac_source=self)
>>           self.verify_status('running') # Throws exception if not
>>
>> -    def needs_restart(self, name, params, basedir):
>> -        """
>> -        Verifies whether the current qemu commandline matches the
>> requested
>> -        one, based on the test parameters.
>> -        """
>> -        if (self.__make_qemu_command() !=
>> -                self.__make_qemu_command(name, params, basedir)):
>> -            logging.debug("VM params in env don't match requested,
>> restarting.")
>> -            return True
>> -        else:
>> -            logging.debug("VM params in env do match requested,
>> continuing.")
>> -            return False
>>
>>       def pause(self):
>>           """
>> diff --git a/client/tests/virt/virttest/libvirt_vm.py
>> b/client/tests/virt/virttest/libvirt_vm.py
>> index 2ec7cf0..4e03835 100644
>> --- a/client/tests/virt/virttest/libvirt_vm.py
>> +++ b/client/tests/virt/virttest/libvirt_vm.py
>> @@ -104,7 +104,7 @@ class VM(virt_vm.BaseVM):
>>
>>           @param name: The name of the object
>>           @param params: A dict containing VM params
>> -                (see method __make_libvirt_command for a full
>> description)
>> +                (see method make_create_command for a full description)
>>           @param root_dir: Base directory for relative filenames
>>           @param address_cache: A dict that maps MAC addresses to IP
>> addresses
>>           @param state: If provided, use this as self.__dict__
>> @@ -250,7 +250,7 @@ class VM(virt_vm.BaseVM):
>>           @param root_dir: Optional new base directory for relative
>> filenames
>>           @param address_cache: A dict that maps MAC addresses to IP
>> addresses
>>           @param copy_state: If True, copy the original VM's state to the
>> clone.
>> -                Mainly useful for __make_libvirt_command().
>> +                Mainly useful for make_create_command().
>>           """
>>           if name is None:
>>               name = self.name
>> @@ -267,7 +267,7 @@ class VM(virt_vm.BaseVM):
>>           return VM(name, params, root_dir, address_cache, state)
>>
>>
>> -    def __make_libvirt_command(self, name=None, params=None,
>> root_dir=None):
>> +    def make_create_command(self, name=None, params=None, root_dir=None):
>>           """
>>           Generate a libvirt command line. All parameters are optional. If
>> a
>>           parameter is not supplied, the corresponding value stored in the
>> @@ -498,7 +498,7 @@ class VM(virt_vm.BaseVM):
>>                       result += ',mac=%s' % mac
>>                   elif mac: # possible to specify --mac w/o --network
>>                       result += " --mac=%s" % mac
>> -            logging.debug("vm.__make_libvirt_command.add_nic returning:
>> %s"
>> +            logging.debug("vm.make_create_command.add_nic returning: %s"
>>                                % result)
>>               return result
>>
>> @@ -723,9 +723,9 @@ class VM(virt_vm.BaseVM):
>>
>>           # setup networking parameters
>>           for nic in vm.virtnet:
>> -            # __make_libvirt_command can be called w/o vm.create()
>> +            # make_create_command can be called w/o vm.create()
>>               nic = vm.add_nic(**dict(nic))
>> -            logging.debug("__make_libvirt_command() setting up command
>> for"
>> +            logging.debug("make_create_command() setting up command for"
>>                             " nic: %s" % str(nic))
>>               virt_install_cmd += add_nic(help,nic)
>>
>> @@ -881,13 +881,13 @@ class VM(virt_vm.BaseVM):
>>                       logging.debug("Copying mac for nic %s from VM %s"
>>                                       % (nic.nic_name, mac_source.nam))
>>                       nic_params['mac'] =
>> mac_source.get_mac_address(nic.nic_name)
>> -                # __make_libvirt_command() calls vm.add_nic (i.e. on a
>> copy)
>> +                # make_create_command() calls vm.add_nic (i.e. on a copy)
>>                   nic = self.add_nic(**nic_params)
>>                   logging.debug('VM.create activating nic %s' % nic)
>>                   self.activate_nic(nic.nic_name)
>>
>>               # Make qemu command
>> -            install_command = self.__make_libvirt_command()
>> +            install_command = self.make_create_command()
>>
>>               logging.info("Running libvirt command (reformatted):")
>>               for item in install_command.replace(" -", " \n
>> -").splitlines():
>> @@ -1184,20 +1184,6 @@ class VM(virt_vm.BaseVM):
>>           return self.wait_for_login(nic_index, timeout=timeout)
>>
>>
>> -    def needs_restart(self, name, params, basedir):
>> -        """
>> -        Verifies whether the current virt_install commandline matches the
>> -        requested one, based on the test parameters.
>> -        """
>> -        if (self.__make_libvirt_command() !=
>> -                self.__make_libvirt_command(name, params, basedir)):
>> -            logging.debug("VM params in env don't match requested,
>> restarting.")
>> -            return True
>> -        else:
>> -            logging.debug("VM params in env do match requested,
>> continuing.")
>> -            return False
>> -
>> -
>>       def screendump(self, filename, debug=False):
>>           if debug:
>>               logging.debug("Requesting screenshot %s" % filename)
>> diff --git a/client/tests/virt/virttest/virt_vm.py
>> b/client/tests/virt/virttest/virt_vm.py
>> index aca2838..f87c766 100644
>> --- a/client/tests/virt/virttest/virt_vm.py
>> +++ b/client/tests/virt/virttest/virt_vm.py
>> @@ -432,6 +432,33 @@ class BaseVM(object):
>>       #
>>       # Public API - could be reimplemented with virt specific code
>>       #
>> +
>> +
>> +    def needs_restart(self, name, params, basedir):
>> +        """
>> +        Verifies whether the current virt_install commandline matches the
>> +        requested one, based on the test parameters.
>> +        """
>> +        if (self.make_create_command() !=
>> +                self.make_create_command(name, params, basedir)):
>> +            logging.debug("VM params in env don't match requested,
>> restarting.")
>> +            return True
>> +        else:
>> +            # Command-line encoded state doesn't include all params
>> +            # TODO: Check more than just networking
>> +            other_virtnet = utils_misc.VirtNet(params, name,
>> self.instance)
>> +            if self.virtnet != other_virtnet
>> +                logging.debug("VM params in env match, but network
>> differs, "
>> +                              "restarting")
>> +                logging.debug("\t" + str(self.virtnet))
>> +                logging.debug("\t!=")
>> +                logging.debug("\t" + str(other_virtnet)
>> +                return True
>> +            else:
>> +                logging.debug("VM params in env do match requested,
>> continuing.")
>> +                return False
>> +
>> +
>>       def verify_alive(self):
>>           """
>>           Make sure the VM is alive and that the main monitor is
>> responsive.
>
>
>
> --
> Chris Evich, RHCA, RHCE, RHCDS, RHCSS
> Quality Assurance Engineer
> e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
>
>
> _______________________________________________
> Autotest-kernel mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/autotest-kernel



-- 
Lucas

_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel

Reply via email to