libvirt/src/hypervisor/domain_driver.h
Laine Stump 24beaffec3 node_device: support binding other drivers with virNodeDeviceDetachFlags()
In the past, the only allowable values for the "driver" field of
virNodeDeviceDetachFlags() were "kvm" or "vfio" for the QEMU driver,
and "xen" for the libxl driver. Then "kvm" was deprecated and removed,
so the driver name became essentially irrelevant (because it is always
called via a particular hypervisor driver, and so the "xen" or "vfio"
can be (and almost always is) implied.

With the advent of VFIO variant drivers, the ability to explicitly
specify a driver name once again becomes useful - it can be used to
name the exact VFIO driver that we want bound to the device in place
of vfio-pci, so this patch allows those other names to be passed down
the call chain, where the code in virpci.c can make use of them.

The names "vfio", "kvm", and "xen" retain their special meaning, though:

  1) because there may be some application or configuration that still
     calls virNodeDeviceDetachFlags() with driverName="vfio", this
     single value is substituted with the synonym of NULL, which means
     "bind the default driver for this device and hypervisor". This
     will currently result in the vfio-pci driver being bound to the
     device.

  2) in the case of the libxl driver, "xen" means to use the standard
     driver used in the case of Xen ("pciback").

  3) "kvm" as a driver name always results in an error, as legacy KVM
     device assignment was removed from the kernel around 10 years ago.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2023-08-24 23:36:18 -04:00

74 lines
3.0 KiB
C

/*
* domain_driver.h: general functions shared between hypervisor drivers
*
* Copyright IBM Corp. 2020
*
* 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/>.
*/
#pragma once
#include "node_device_conf.h"
#include "virhostdev.h"
#include "virpci.h"
char *
virDomainDriverGenerateRootHash(const char *drivername,
const char *root);
char *
virDomainDriverGenerateMachineName(const char *drivername,
const char *root,
int id,
const char *name,
bool privileged);
int virDomainDriverMergeBlkioDevice(virBlkioDevice **dest_array,
size_t *dest_size,
virBlkioDevice *src_array,
size_t src_size,
const char *type);
int virDomainDriverParseBlkioDeviceStr(char *blkioDeviceStr, const char *type,
virBlkioDevice **dev, size_t *size);
int virDomainDriverSetupPersistentDefBlkioParams(virDomainDef *persistentDef,
virTypedParameterPtr params,
int nparams);
int virDomainDriverNodeDeviceGetPCIInfo(virNodeDeviceDef *def,
virPCIDeviceAddress *devAddr);
int virDomainDriverNodeDeviceReset(virNodeDevicePtr dev,
virHostdevManager *hostdevMgr);
int virDomainDriverNodeDeviceReAttach(virNodeDevicePtr dev,
virHostdevManager *hostdevMgr);
int virDomainDriverNodeDeviceDetachFlags(virNodeDevicePtr dev,
virHostdevManager *hostdevMgr,
virPCIStubDriver driverType,
const char *driverName);
int virDomainDriverAddIOThreadCheck(virDomainDef *def,
unsigned int iothread_id);
int virDomainDriverDelIOThreadCheck(virDomainDef *def,
unsigned int iothread_id);
int virDomainDriverGetIOThreadsConfig(virDomainDef *targetDef,
virDomainIOThreadInfoPtr **info,
unsigned int bitmap_size);