2014-02-18 10:08:10 +00:00
|
|
|
/*
|
2014-03-07 13:38:51 +00:00
|
|
|
* bhyve_command.c: bhyve command generation
|
2014-02-18 10:08:10 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Roman Bogorodskiy
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_tap.h>
|
|
|
|
|
|
|
|
#include "bhyve_command.h"
|
|
|
|
#include "viralloc.h"
|
|
|
|
#include "virfile.h"
|
|
|
|
#include "virstring.h"
|
|
|
|
#include "virlog.h"
|
|
|
|
#include "virnetdev.h"
|
|
|
|
#include "virnetdevbridge.h"
|
|
|
|
#include "virnetdevtap.h"
|
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_BHYVE
|
|
|
|
|
2014-02-28 12:16:17 +00:00
|
|
|
VIR_LOG_INIT("bhyve.bhyve_command");
|
|
|
|
|
2014-02-18 10:08:10 +00:00
|
|
|
static int
|
2014-04-12 19:37:53 +00:00
|
|
|
bhyveBuildNetArgStr(const virDomainDef *def,
|
|
|
|
virDomainNetDefPtr net,
|
|
|
|
virCommandPtr cmd,
|
|
|
|
bool dryRun)
|
2014-02-18 10:08:10 +00:00
|
|
|
{
|
2014-04-12 19:37:53 +00:00
|
|
|
char macaddr[VIR_MAC_STRING_BUFLEN];
|
2014-02-18 10:08:10 +00:00
|
|
|
char *realifname = NULL;
|
2014-04-12 19:37:53 +00:00
|
|
|
char *brname = NULL;
|
|
|
|
int actualType = virDomainNetGetActualType(net);
|
2014-02-18 10:08:10 +00:00
|
|
|
|
2014-04-12 19:37:53 +00:00
|
|
|
if (actualType == VIR_DOMAIN_NET_TYPE_BRIDGE) {
|
|
|
|
if (VIR_STRDUP(brname, virDomainNetGetActualBridgeName(net)) < 0)
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
|
|
_("Network type %d is not supported"),
|
|
|
|
virDomainNetGetActualType(net));
|
2014-02-18 10:08:10 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-04-12 19:37:53 +00:00
|
|
|
if (!net->ifname ||
|
|
|
|
STRPREFIX(net->ifname, VIR_NET_GENERATED_PREFIX) ||
|
|
|
|
strchr(net->ifname, '%')) {
|
|
|
|
VIR_FREE(net->ifname);
|
|
|
|
if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_PREFIX "%d") < 0) {
|
|
|
|
VIR_FREE(brname);
|
2014-02-18 10:08:10 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2014-04-12 19:37:53 +00:00
|
|
|
}
|
2014-02-18 10:08:10 +00:00
|
|
|
|
2014-04-12 19:37:53 +00:00
|
|
|
if (!dryRun) {
|
|
|
|
if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
|
2014-06-13 16:14:53 +00:00
|
|
|
def->uuid, NULL, 0,
|
2014-04-12 19:37:53 +00:00
|
|
|
virDomainNetGetActualVirtPortProfile(net),
|
|
|
|
virDomainNetGetActualVlan(net),
|
|
|
|
VIR_NETDEV_TAP_CREATE_IFUP | VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {
|
2014-02-18 10:08:10 +00:00
|
|
|
VIR_FREE(net->ifname);
|
2014-04-12 19:37:53 +00:00
|
|
|
VIR_FREE(brname);
|
|
|
|
return -1;
|
2014-02-18 10:08:10 +00:00
|
|
|
}
|
|
|
|
|
2014-04-13 09:27:03 +00:00
|
|
|
realifname = virNetDevTapGetRealDeviceName(net->ifname);
|
|
|
|
|
|
|
|
if (realifname == NULL) {
|
2014-02-18 10:08:10 +00:00
|
|
|
VIR_FREE(net->ifname);
|
|
|
|
VIR_FREE(brname);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-04-13 09:27:03 +00:00
|
|
|
VIR_DEBUG("%s -> %s", net->ifname, realifname);
|
|
|
|
/* hack on top of other hack: we need to set
|
|
|
|
* interface to 'UP' again after re-opening to find its
|
|
|
|
* name
|
|
|
|
*/
|
|
|
|
if (virNetDevSetOnline(net->ifname, true) != 0) {
|
2014-04-12 19:37:53 +00:00
|
|
|
VIR_FREE(realifname);
|
2014-04-13 09:27:03 +00:00
|
|
|
VIR_FREE(net->ifname);
|
|
|
|
VIR_FREE(brname);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (VIR_STRDUP(realifname, "tap0") < 0)
|
|
|
|
return -1;
|
2014-02-18 10:08:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virCommandAddArg(cmd, "-s");
|
2014-04-12 19:37:53 +00:00
|
|
|
virCommandAddArgFormat(cmd, "%d:0,virtio-net,%s,mac=%s",
|
|
|
|
net->info.addr.pci.slot,
|
2014-03-20 08:39:21 +00:00
|
|
|
realifname, virMacAddrFormat(&net->mac, macaddr));
|
2014-04-12 19:37:53 +00:00
|
|
|
VIR_FREE(realifname);
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-03-15 12:30:01 +00:00
|
|
|
static int
|
|
|
|
bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
virDomainChrDefPtr chr = NULL;
|
|
|
|
|
|
|
|
if (!def->nserials)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
chr = def->serials[0];
|
|
|
|
|
|
|
|
if (chr->source.type != VIR_DOMAIN_CHR_TYPE_NMDM) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("only nmdm console types are supported"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bhyve supports only two ports: com1 and com2 */
|
|
|
|
if (chr->target.port > 2) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("only two serial ports are supported"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-04-12 19:37:53 +00:00
|
|
|
virCommandAddArgList(cmd, "-s", "1,lpc", NULL);
|
2014-03-15 12:30:01 +00:00
|
|
|
virCommandAddArg(cmd, "-l");
|
|
|
|
virCommandAddArgFormat(cmd, "com%d,%s",
|
|
|
|
chr->target.port + 1, chr->source.data.file.path);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:08:10 +00:00
|
|
|
static int
|
2014-04-12 19:37:53 +00:00
|
|
|
bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
|
|
|
|
virDomainDiskDefPtr disk,
|
|
|
|
virCommandPtr cmd)
|
2014-02-18 10:08:10 +00:00
|
|
|
{
|
2014-03-15 14:52:19 +00:00
|
|
|
const char *bus_type;
|
2014-07-19 15:15:26 +00:00
|
|
|
const char *disk_source;
|
2014-02-18 10:08:10 +00:00
|
|
|
|
2014-03-15 14:52:19 +00:00
|
|
|
switch (disk->bus) {
|
|
|
|
case VIR_DOMAIN_DISK_BUS_SATA:
|
2014-07-19 15:15:26 +00:00
|
|
|
switch (disk->device) {
|
|
|
|
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
|
|
|
bus_type = "ahci-hd";
|
|
|
|
break;
|
|
|
|
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
|
|
|
bus_type = "ahci-cd";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("unsupported disk device"));
|
|
|
|
return -1;
|
|
|
|
}
|
2014-03-15 14:52:19 +00:00
|
|
|
break;
|
|
|
|
case VIR_DOMAIN_DISK_BUS_VIRTIO:
|
2014-07-19 15:15:26 +00:00
|
|
|
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
|
|
|
bus_type = "virtio-blk";
|
|
|
|
} else {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("unsupported disk device"));
|
|
|
|
return -1;
|
|
|
|
}
|
2014-03-15 14:52:19 +00:00
|
|
|
break;
|
|
|
|
default:
|
2014-02-18 10:08:10 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("unsupported disk bus type"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) {
|
2014-02-18 10:08:10 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("unsupported disk type"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-07-19 15:15:26 +00:00
|
|
|
disk_source = virDomainDiskGetSource(disk);
|
|
|
|
|
|
|
|
if ((disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
|
|
|
|
(disk_source == NULL)) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("cdrom device without source path "
|
|
|
|
"not supported"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-02-18 10:08:10 +00:00
|
|
|
virCommandAddArg(cmd, "-s");
|
2014-04-12 19:37:53 +00:00
|
|
|
virCommandAddArgFormat(cmd, "%d:0,%s,%s",
|
|
|
|
disk->info.addr.pci.slot, bus_type,
|
2014-07-19 15:15:26 +00:00
|
|
|
disk_source);
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
virCommandPtr
|
|
|
|
virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
2014-04-13 09:27:03 +00:00
|
|
|
virDomainDefPtr def, bool dryRun)
|
2014-02-18 10:08:10 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* /usr/sbin/bhyve -c 2 -m 256 -AI -H -P \
|
|
|
|
* -s 0:0,hostbridge \
|
|
|
|
* -s 1:0,virtio-net,tap0 \
|
|
|
|
* -s 2:0,ahci-hd,${IMG} \
|
|
|
|
* -S 31,uart,stdio \
|
|
|
|
* vm0
|
|
|
|
*/
|
2014-04-12 19:37:53 +00:00
|
|
|
size_t i;
|
|
|
|
|
2014-02-18 10:08:10 +00:00
|
|
|
virCommandPtr cmd = virCommandNew(BHYVE);
|
|
|
|
|
|
|
|
/* CPUs */
|
|
|
|
virCommandAddArg(cmd, "-c");
|
2014-04-13 09:27:03 +00:00
|
|
|
virCommandAddArgFormat(cmd, "%d", def->vcpus);
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
/* Memory */
|
|
|
|
virCommandAddArg(cmd, "-m");
|
|
|
|
virCommandAddArgFormat(cmd, "%llu",
|
2014-04-13 09:27:03 +00:00
|
|
|
VIR_DIV_UP(def->mem.max_balloon, 1024));
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
/* Options */
|
2014-06-27 15:18:53 +00:00
|
|
|
if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON)
|
2014-02-18 10:08:10 +00:00
|
|
|
virCommandAddArg(cmd, "-A"); /* Create an ACPI table */
|
2014-06-27 15:18:53 +00:00
|
|
|
if (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON)
|
2014-02-18 10:08:10 +00:00
|
|
|
virCommandAddArg(cmd, "-I"); /* Present ioapic to the guest */
|
|
|
|
|
|
|
|
/* Clarification about -H and -P flags from Peter Grehan:
|
|
|
|
* -H and -P flags force the guest to exit when it executes IA32 HLT and PAUSE
|
|
|
|
* instructions respectively.
|
|
|
|
*
|
|
|
|
* For the HLT exit, bhyve uses that to infer that the guest is idling and can
|
|
|
|
* be put to sleep until an external event arrives. If this option is not used,
|
|
|
|
* the guest will always use 100% of CPU on the host.
|
|
|
|
*
|
|
|
|
* The PAUSE exit is most useful when there are large numbers of guest VMs running,
|
|
|
|
* since it forces the guest to exit when it spins on a lock acquisition.
|
|
|
|
*/
|
|
|
|
virCommandAddArg(cmd, "-H"); /* vmexit from guest on hlt */
|
|
|
|
virCommandAddArg(cmd, "-P"); /* vmexit from guest on pause */
|
|
|
|
|
2014-03-15 15:17:14 +00:00
|
|
|
virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL);
|
2014-02-18 10:08:10 +00:00
|
|
|
/* Devices */
|
2014-04-12 19:37:53 +00:00
|
|
|
for (i = 0; i < def->nnets; i++) {
|
|
|
|
virDomainNetDefPtr net = def->nets[i];
|
|
|
|
if (bhyveBuildNetArgStr(def, net, cmd, dryRun) < 0)
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
for (i = 0; i < def->ndisks; i++) {
|
|
|
|
virDomainDiskDefPtr disk = def->disks[i];
|
|
|
|
|
|
|
|
if (bhyveBuildDiskArgStr(def, disk, cmd) < 0)
|
|
|
|
goto error;
|
|
|
|
}
|
2014-04-13 09:27:03 +00:00
|
|
|
if (bhyveBuildConsoleArgStr(def, cmd) < 0)
|
2014-03-15 12:30:01 +00:00
|
|
|
goto error;
|
2014-04-13 09:27:03 +00:00
|
|
|
virCommandAddArg(cmd, def->name);
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
return cmd;
|
|
|
|
|
2014-03-25 06:57:22 +00:00
|
|
|
error:
|
2014-02-18 10:08:10 +00:00
|
|
|
virCommandFree(cmd);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
virCommandPtr
|
|
|
|
virBhyveProcessBuildDestroyCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
2014-04-13 09:27:03 +00:00
|
|
|
virDomainDefPtr def)
|
2014-02-18 10:08:10 +00:00
|
|
|
{
|
|
|
|
virCommandPtr cmd = virCommandNew(BHYVECTL);
|
|
|
|
|
|
|
|
virCommandAddArg(cmd, "--destroy");
|
2014-04-13 09:27:03 +00:00
|
|
|
virCommandAddArgPair(cmd, "--vm", def->name);
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
return cmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
virCommandPtr
|
|
|
|
virBhyveProcessBuildLoadCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED,
|
2014-04-13 09:27:03 +00:00
|
|
|
virDomainDefPtr def)
|
2014-02-18 10:08:10 +00:00
|
|
|
{
|
|
|
|
virCommandPtr cmd;
|
|
|
|
virDomainDiskDefPtr disk;
|
|
|
|
|
2014-04-12 19:37:53 +00:00
|
|
|
if (def->ndisks < 1) {
|
2014-02-18 10:08:10 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
2014-04-12 19:37:53 +00:00
|
|
|
_("domain should have at least one disk defined"));
|
2014-02-18 10:08:10 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-04-13 09:27:03 +00:00
|
|
|
disk = def->disks[0];
|
2014-02-18 10:08:10 +00:00
|
|
|
|
2014-07-19 15:15:26 +00:00
|
|
|
if ((disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) &&
|
|
|
|
(disk->device != VIR_DOMAIN_DISK_DEVICE_CDROM)) {
|
2014-02-18 10:08:10 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("unsupported disk device"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) {
|
2014-02-18 10:08:10 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("unsupported disk type"));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd = virCommandNew(BHYVELOAD);
|
|
|
|
|
|
|
|
/* Memory */
|
|
|
|
virCommandAddArg(cmd, "-m");
|
|
|
|
virCommandAddArgFormat(cmd, "%llu",
|
2014-04-13 09:27:03 +00:00
|
|
|
VIR_DIV_UP(def->mem.max_balloon, 1024));
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
/* Image path */
|
|
|
|
virCommandAddArg(cmd, "-d");
|
2014-03-19 12:31:04 +00:00
|
|
|
virCommandAddArg(cmd, virDomainDiskGetSource(disk));
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
/* VM name */
|
2014-04-13 09:27:03 +00:00
|
|
|
virCommandAddArg(cmd, def->name);
|
2014-02-18 10:08:10 +00:00
|
|
|
|
|
|
|
return cmd;
|
|
|
|
}
|