mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
ch: prepare host for PCI passthrough
Prepare host to passthrough PCI devices for ch guests. Co-authored-by: Wei Liu <liuwe@microsoft.com> Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
acfe2e7a50
commit
c6dbc6042d
@ -22,11 +22,31 @@
|
||||
|
||||
#include "ch_hostdev.h"
|
||||
#include "virlog.h"
|
||||
#include "virerror.h"
|
||||
#include "virhostdev.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_CH
|
||||
|
||||
VIR_LOG_INIT("ch.ch_hostdev");
|
||||
|
||||
int
|
||||
virCHHostdevPrepareDomainDevices(virCHDriver *driver,
|
||||
virDomainDef *def,
|
||||
unsigned int flags)
|
||||
|
||||
{
|
||||
if (!def->nhostdevs)
|
||||
return 0;
|
||||
|
||||
if (virHostdevPreparePCIDevices(driver->hostdevMgr, CH_DRIVER_NAME,
|
||||
def->name, def->uuid,
|
||||
def->hostdevs, def->nhostdevs,
|
||||
flags) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
virCHDomainPrepareHostdevPCI(virDomainHostdevDef *hostdev)
|
||||
{
|
||||
|
@ -25,3 +25,8 @@
|
||||
|
||||
int
|
||||
virCHDomainPrepareHostdev(virDomainHostdevDef *hostdev);
|
||||
|
||||
int
|
||||
virCHHostdevPrepareDomainDevices(virCHDriver *driver,
|
||||
virDomainDef *def,
|
||||
unsigned int flags);
|
||||
|
@ -824,6 +824,33 @@ virCHProcessPrepareDomainHostdevs(virDomainObj *vm)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* virCHProcessPrepareHost:
|
||||
* @driver: ch driver
|
||||
* @vm: domain object
|
||||
*
|
||||
* This function groups all code that modifies host system to prepare
|
||||
* environment for a domain which is about to start.
|
||||
*
|
||||
* This function MUST be called only after virCHProcessPrepareDomain().
|
||||
*/
|
||||
static int
|
||||
virCHProcessPrepareHost(virCHDriver *driver, virDomainObj *vm)
|
||||
{
|
||||
unsigned int hostdev_flags = 0;
|
||||
virCHDomainObjPrivate *priv = vm->privateData;
|
||||
g_autoptr(virCHDriverConfig) cfg = virCHDriverGetConfig(driver);
|
||||
|
||||
if (virCHHostdevPrepareDomainDevices(driver, vm->def, hostdev_flags) < 0)
|
||||
return -1;
|
||||
|
||||
/* Ensure no historical cgroup for this VM is lying around */
|
||||
VIR_DEBUG("Ensuring no historical cgroup is lying around");
|
||||
virDomainCgroupRemoveCgroup(vm, priv->cgroup, priv->machineName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* virCHProcessPrepareDomain:
|
||||
* @vm: domain object
|
||||
@ -878,6 +905,9 @@ virCHProcessStart(virCHDriver *driver,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virCHProcessPrepareHost(driver, vm) < 0)
|
||||
return -1;
|
||||
|
||||
if (!priv->monitor) {
|
||||
/* And we can get the first monitor connection now too */
|
||||
if (!(priv->monitor = virCHProcessConnectMonitor(driver, vm))) {
|
||||
|
Loading…
Reference in New Issue
Block a user