[libvirt] [v10 1/6] add hostdev passthrough common library

Jim Fehlig jfehlig at suse.com
Mon Jan 20 23:23:50 UTC 2014


Jim Fehlig wrote:
> Chunyan Liu wrote:
>   
>> Extract code from qemu_hostdev.c and make it reusable for multiple drivers,
>> meanwhile maintain a global hostdev state to solve conflict between different
>> drivers.
>>
>> Signed-off-by: Chunyan Liu <cyliu at suse.com>
>> ---
>>  .gnulib                  |    2 +-
>>  po/POTFILES.in           |    1 +
>>  src/Makefile.am          |    1 +
>>  src/libvirt_private.syms |   21 +
>>  src/lxc/lxc_hostdev.c    |   11 +-
>>  src/qemu/qemu_driver.c   |    4 +-
>>  src/qemu/qemu_hostdev.c  |   42 +-
>>  src/util/virhostdev.c    | 1691 ++++++++++++++++++++++++++++++++++++++++++++++
>>  src/util/virhostdev.h    |  134 ++++
>>  src/util/virpci.c        |   30 +-
>>  src/util/virpci.h        |    9 +-
>>  src/util/virscsi.c       |   28 +-
>>  src/util/virscsi.h       |    8 +-
>>  src/util/virusb.c        |   29 +-
>>  src/util/virusb.h        |    8 +-
>>  15 files changed, 1970 insertions(+), 49 deletions(-)
>>  create mode 100644 src/util/virhostdev.c
>>  create mode 100644 src/util/virhostdev.h
>>
>> diff --git a/.gnulib b/.gnulib
>> index d18d1b8..831b84c 160000
>> --- a/.gnulib
>> +++ b/.gnulib
>> @@ -1 +1 @@
>> -Subproject commit d18d1b8023822220bb8f0a079c7312a1adffdce0
>> +Subproject commit 831b84c59ef413c57a36b67344467d66a8a2ba70
>>   
>>     
>
> Oops, looks like you needed to update gnulib.
>   

[...]

>> diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
>> new file mode 100644
>> index 0000000..e15a70d
>> --- /dev/null
>> +++ b/src/util/virhostdev.h
>> @@ -0,0 +1,134 @@
>> +/* virhostdev.h: hostdev management
>> + *
>> + * Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
>> + * Copyright (C) 2006-2007, 2009-2014 Red Hat, Inc.
>> + * Copyright (C) 2006 Daniel P. Berrange
>> + *
>> + * This library is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * This library is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this library.  If not, see
>> + * <http://www.gnu.org/licenses/>.
>> + *
>> + * Author: Chunyan Liu <cyliu at suse.com>
>> + * Author: Daniel P. Berrange <berrange at redhat.com>
>> + */
>> +
>> +#ifndef __VIR_HOSTDEV_H__
>> +# define __VIR_HOSTDEV_H__
>> +
>> +# include "internal.h"
>> +
>> +# include "domain_conf.h"
>> +# include "virpci.h"
>> +# include "virusb.h"
>> +# include "virscsi.h"
>> +
>> +typedef enum {
>> +    VIR_SP_PCI_HOSTDEV       = (1 << 0), /* support pci passthrough */
>> +    VIR_SP_USB_HOSTDEV       = (1 << 1), /* support usb passthrough */
>> +    VIR_SP_SCSI_HOSTDEV      = (1 << 2), /* support scsi passthrough */
>> +
>> +    VIR_COLD_BOOT            = (1 << 8), /* cold boot */
>> +    VIR_STRICT_ACS_CHECK     = (1 << 9), /* strict acs check */
>> +} virHostdevManagerFlag;
>> +
>> +typedef struct _virHostdevManager virHostdevManager;
>> +typedef virHostdevManager *virHostdevManagerPtr;
>> +struct _virHostdevManager{
>> +    char *stateDir;
>> +
>> +    virPCIDeviceListPtr activePciHostdevs;
>> +    virPCIDeviceListPtr inactivePciHostdevs;
>> +    virUSBDeviceListPtr activeUsbHostdevs;
>> +    virSCSIDeviceListPtr activeScsiHostdevs;
>> +};
>> +
>> +virHostdevManagerPtr virHostdevManagerGetDefault(void);
>> +
>> +bool virHostdevHostSupportsPassthroughVFIO(void);
>> +bool virHostdevHostSupportsPassthroughKVM(void);
>>     

While rebasing 3/6, noticed the name change here from
SupportsPassthroughLegacy to SupportsPassthroughKVM. IMO, we should
stick with the existing name.

Regards,
Jim




More information about the libvir-list mailing list