2014-03-04 20:38 GMT+08:00 Daniel P. Berrange <berrange@redhat.com>:
On Sat, Mar 01, 2014 at 02:29:00PM +0800, Chunyan Liu wrote:
>
> Signed-off-by: Chunyan Liu <cyliu@suse.com>
> ---
>  src/qemu/qemu_conf.h    |    8 --
>  src/qemu/qemu_driver.c  |   74 +++++++++----------
>  src/qemu/qemu_hostdev.c |  192 ++++++++++++++++++++++++++++-------------------
>  src/qemu/qemu_hotplug.c |    1 +
>  4 files changed, 151 insertions(+), 124 deletions(-)
>
> diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
> index ece185b..2ac88fb 100644
> --- a/src/qemu/qemu_conf.h
> +++ b/src/qemu/qemu_conf.h
> @@ -215,14 +215,6 @@ struct _virQEMUDriver {
>      /* Immutable pointer. self-locking APIs */
>      virSecurityManagerPtr securityManager;
>
> -    /* Immutable pointers. Requires locks to be held before
> -     * calling APIs. activePciHostdevs must be locked before
> -     * inactivePciHostdevs */
> -    virPCIDeviceListPtr activePciHostdevs;
> -    virPCIDeviceListPtr inactivePciHostdevs;
> -    virUSBDeviceListPtr activeUsbHostdevs;
> -    virSCSIDeviceListPtr activeScsiHostdevs;
> -
>      /* Immutable pointer. Unsafe APIs. XXX */
>      virHashTablePtr sharedDevices;
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index f36a8b4..7d924b2 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -95,6 +95,7 @@
>  #include "viraccessapicheck.h"
>  #include "viraccessapicheckqemu.h"
>  #include "storage/storage_driver.h"
> +#include "virhostdev.h"
>
>  #define VIR_FROM_THIS VIR_FROM_QEMU
>
> @@ -695,18 +696,6 @@ qemuStateInitialize(bool privileged,
>      if (qemuSecurityInit(qemu_driver) < 0)
>          goto error;
>
> -    if ((qemu_driver->activePciHostdevs = virPCIDeviceListNew()) == NULL)
> -        goto error;
> -
> -    if ((qemu_driver->activeUsbHostdevs = virUSBDeviceListNew()) == NULL)
> -        goto error;
> -
> -    if ((qemu_driver->inactivePciHostdevs = virPCIDeviceListNew()) == NULL)
> -        goto error;
> -
> -    if ((qemu_driver->activeScsiHostdevs = virSCSIDeviceListNew()) == NULL)
> -        goto error;
> -

I think we should obtain the hostdev manager instance here, and save a
reference to it, so that later functions do not need to worry about
failure of virHostdevManagerGetDefault()

we could:
 add .hostdev_mgr to _virQEMUDriver, and add
 qemu_driver->hostdev_mgr = virHostdevManagerGetDefault() here.
 Is that OK?


> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 5546693..eeb1f24 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -50,6 +50,7 @@
>  #include "virstoragefile.h"
>  #include "virstring.h"
>  #include "virtime.h"
> +#include "virhostdev.h"

This seems bogus as you're not adding any code to this file which would
use those APIs

Regards,
Daniel
--
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|