mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
bhyve: add volumes support
Update bhyveBuildDiskArgStr to support volumes: - Make virBhyveProcessBuildBhyveCmd and virBhyveProcessBuildLoadCmd take virConnectPtr as the first argument instead of bhyveConnPtr as virConnectPtr is needed for virStorageTranslateDiskSourcePool, - Add virStorageTranslateDiskSourcePool call to virBhyveProcessBuildBhyveCmd and virBhyveProcessBuildLoadCmd, - Allow disks of type VIR_STORAGE_TYPE_VOLUME
This commit is contained in:
parent
8c170c9fe6
commit
6c2e7d0b17
@ -33,6 +33,7 @@
|
||||
#include "virnetdev.h"
|
||||
#include "virnetdevbridge.h"
|
||||
#include "virnetdevtap.h"
|
||||
#include "storage/storage_driver.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_BHYVE
|
||||
|
||||
@ -184,7 +185,8 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) {
|
||||
if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) &&
|
||||
(virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("unsupported disk type"));
|
||||
return -1;
|
||||
@ -209,7 +211,7 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
virCommandPtr
|
||||
virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
||||
virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
|
||||
virDomainDefPtr def, bool dryRun)
|
||||
{
|
||||
/*
|
||||
@ -263,6 +265,9 @@ virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
||||
for (i = 0; i < def->ndisks; i++) {
|
||||
virDomainDiskDefPtr disk = def->disks[i];
|
||||
|
||||
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
|
||||
goto error;
|
||||
|
||||
if (bhyveBuildDiskArgStr(def, disk, cmd) < 0)
|
||||
goto error;
|
||||
}
|
||||
@ -290,7 +295,7 @@ virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
virCommandPtr
|
||||
virBhyveProcessBuildLoadCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
||||
virBhyveProcessBuildLoadCmd(virConnectPtr conn,
|
||||
virDomainDefPtr def)
|
||||
{
|
||||
virCommandPtr cmd;
|
||||
@ -304,6 +309,9 @@ virBhyveProcessBuildLoadCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
||||
|
||||
disk = def->disks[0];
|
||||
|
||||
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
|
||||
return NULL;
|
||||
|
||||
if ((disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) &&
|
||||
(disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
@ -311,7 +319,8 @@ virBhyveProcessBuildLoadCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) {
|
||||
if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) &&
|
||||
(virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("unsupported disk type"));
|
||||
return NULL;
|
||||
|
@ -29,15 +29,16 @@
|
||||
|
||||
# define BHYVE_CONFIG_FORMAT_ARGV "bhyve-argv"
|
||||
|
||||
virCommandPtr virBhyveProcessBuildBhyveCmd(bhyveConnPtr,
|
||||
virDomainDefPtr def, bool dryRun);
|
||||
virCommandPtr virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
|
||||
virDomainDefPtr def,
|
||||
bool dryRun);
|
||||
|
||||
virCommandPtr
|
||||
virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver,
|
||||
virDomainDefPtr def);
|
||||
|
||||
virCommandPtr
|
||||
virBhyveProcessBuildLoadCmd(bhyveConnPtr driver,
|
||||
virBhyveProcessBuildLoadCmd(virConnectPtr conn,
|
||||
virDomainDefPtr def);
|
||||
|
||||
#endif /* __BHYVE_COMMAND_H__ */
|
||||
|
@ -689,10 +689,10 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
|
||||
if (bhyveDomainAssignAddresses(def, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(loadcmd = virBhyveProcessBuildLoadCmd(privconn, def)))
|
||||
if (!(loadcmd = virBhyveProcessBuildLoadCmd(conn, def)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(cmd = virBhyveProcessBuildBhyveCmd(privconn, def, true)))
|
||||
if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, def, true)))
|
||||
goto cleanup;
|
||||
|
||||
virBufferAdd(&buf, virCommandToString(loadcmd), -1);
|
||||
|
@ -137,7 +137,7 @@ virBhyveProcessStart(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
|
||||
/* Call bhyve to start the VM */
|
||||
if (!(cmd = virBhyveProcessBuildBhyveCmd(driver,
|
||||
if (!(cmd = virBhyveProcessBuildBhyveCmd(conn,
|
||||
vm->def,
|
||||
false)))
|
||||
goto cleanup;
|
||||
@ -151,7 +151,7 @@ virBhyveProcessStart(virConnectPtr conn,
|
||||
/* Now bhyve command is constructed, meaning the
|
||||
* domain is ready to be started, so we can build
|
||||
* and execute bhyveload command */
|
||||
if (!(load_cmd = virBhyveProcessBuildLoadCmd(driver, vm->def)))
|
||||
if (!(load_cmd = virBhyveProcessBuildLoadCmd(conn, vm->def)))
|
||||
goto cleanup;
|
||||
virCommandSetOutputFD(load_cmd, &logfd);
|
||||
virCommandSetErrorFD(load_cmd, &logfd);
|
||||
|
@ -674,6 +674,9 @@ bhyvexml2argvmock_la_LDFLAGS = -module -avoid-version \
|
||||
-rpath /evil/libtool/hack/to/force/shared/lib/creation
|
||||
|
||||
bhyve_LDADDS = ../src/libvirt_driver_bhyve_impl.la
|
||||
if WITH_STORAGE
|
||||
bhyve_LDADDS += ../src/libvirt_driver_storage_impl.la
|
||||
endif WITH_STORAGE
|
||||
bhyve_LDADDS += $(LDADDS)
|
||||
bhyvexml2argvtest_SOURCES = \
|
||||
bhyvexml2argvtest.c \
|
||||
|
@ -23,8 +23,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
||||
virDomainDefPtr vmdef = NULL;
|
||||
virDomainObj vm;
|
||||
virCommandPtr cmd = NULL;
|
||||
virConnectPtr conn;
|
||||
int ret = -1;
|
||||
|
||||
if (!(conn = virGetConnect()))
|
||||
goto out;
|
||||
|
||||
if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
|
||||
1 << VIR_DOMAIN_VIRT_BHYVE,
|
||||
@ -33,7 +36,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
||||
|
||||
vm.def = vmdef;
|
||||
|
||||
if (!(cmd = virBhyveProcessBuildBhyveCmd(&driver, vmdef, false)))
|
||||
if (!(cmd = virBhyveProcessBuildBhyveCmd(conn, vmdef, false)))
|
||||
goto out;
|
||||
|
||||
if (!(actualargv = virCommandToString(cmd)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user