mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
virCaps: get rid of hasWideScsiBus
Use the virDomainXMLConf structure to hold this data.
This commit is contained in:
parent
b299084988
commit
8960d65674
@ -164,7 +164,6 @@ struct _virCaps {
|
|||||||
/* Move to virDomainXMLOption later */
|
/* Move to virDomainXMLOption later */
|
||||||
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
|
unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
|
||||||
int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
|
int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
|
||||||
bool hasWideScsiBus;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -3593,7 +3593,8 @@ virDomainDiskFindByBusAndDst(virDomainDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def)
|
virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
|
||||||
|
virDomainDiskDefPtr def)
|
||||||
{
|
{
|
||||||
int idx = virDiskNameToIndex(def->dst);
|
int idx = virDiskNameToIndex(def->dst);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
@ -3607,7 +3608,7 @@ virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def)
|
|||||||
case VIR_DOMAIN_DISK_BUS_SCSI:
|
case VIR_DOMAIN_DISK_BUS_SCSI:
|
||||||
def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
|
def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE;
|
||||||
|
|
||||||
if (caps->hasWideScsiBus) {
|
if (xmlopt->config.hasWideScsiBus) {
|
||||||
/* For a wide SCSI bus we define the default mapping to be
|
/* For a wide SCSI bus we define the default mapping to be
|
||||||
* 16 units per bus, 1 bus per controller, many controllers.
|
* 16 units per bus, 1 bus per controller, many controllers.
|
||||||
* Unit 7 is the SCSI controller itself. Therefore unit 7
|
* Unit 7 is the SCSI controller itself. Therefore unit 7
|
||||||
@ -4046,7 +4047,7 @@ cleanup:
|
|||||||
* @param node XML nodeset to parse for disk definition
|
* @param node XML nodeset to parse for disk definition
|
||||||
*/
|
*/
|
||||||
static virDomainDiskDefPtr
|
static virDomainDiskDefPtr
|
||||||
virDomainDiskDefParseXML(virCapsPtr caps,
|
virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
|
||||||
xmlNodePtr node,
|
xmlNodePtr node,
|
||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
virBitmapPtr bootMap,
|
virBitmapPtr bootMap,
|
||||||
@ -4837,7 +4838,7 @@ virDomainDiskDefParseXML(virCapsPtr caps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
|
if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
|
||||||
&& virDomainDiskDefAssignAddress(caps, def) < 0)
|
&& virDomainDiskDefAssignAddress(xmlopt, def) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -8499,7 +8500,7 @@ virDomainDeviceDefParse(const char *xmlStr,
|
|||||||
|
|
||||||
if (xmlStrEqual(node->name, BAD_CAST "disk")) {
|
if (xmlStrEqual(node->name, BAD_CAST "disk")) {
|
||||||
dev->type = VIR_DOMAIN_DEVICE_DISK;
|
dev->type = VIR_DOMAIN_DEVICE_DISK;
|
||||||
if (!(dev->data.disk = virDomainDiskDefParseXML(caps, node, ctxt,
|
if (!(dev->data.disk = virDomainDiskDefParseXML(xmlopt, node, ctxt,
|
||||||
NULL, def->seclabels,
|
NULL, def->seclabels,
|
||||||
def->nseclabels,
|
def->nseclabels,
|
||||||
flags)))
|
flags)))
|
||||||
@ -10391,7 +10392,7 @@ virDomainDefParseXML(xmlDocPtr xml,
|
|||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
for (i = 0 ; i < n ; i++) {
|
for (i = 0 ; i < n ; i++) {
|
||||||
virDomainDiskDefPtr disk = virDomainDiskDefParseXML(caps,
|
virDomainDiskDefPtr disk = virDomainDiskDefParseXML(xmlopt,
|
||||||
nodes[i],
|
nodes[i],
|
||||||
ctxt,
|
ctxt,
|
||||||
bootMap,
|
bootMap,
|
||||||
|
@ -1949,11 +1949,16 @@ typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
|
|||||||
typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
|
typedef struct _virDomainDefParserConfig virDomainDefParserConfig;
|
||||||
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
|
typedef virDomainDefParserConfig *virDomainDefParserConfigPtr;
|
||||||
struct _virDomainDefParserConfig {
|
struct _virDomainDefParserConfig {
|
||||||
|
/* driver domain definition callbacks */
|
||||||
virDomainDefPostParseCallback domainPostParseCallback;
|
virDomainDefPostParseCallback domainPostParseCallback;
|
||||||
virDomainDeviceDefPostParseCallback devicesPostParseCallback;
|
virDomainDeviceDefPostParseCallback devicesPostParseCallback;
|
||||||
|
|
||||||
|
/* private data for the callbacks */
|
||||||
void *priv;
|
void *priv;
|
||||||
virFreeCallback privFree;
|
virFreeCallback privFree;
|
||||||
|
|
||||||
|
/* data */
|
||||||
|
bool hasWideScsiBus;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
|
typedef struct _virDomainXMLPrivateDataCallbacks virDomainXMLPrivateDataCallbacks;
|
||||||
@ -2151,7 +2156,8 @@ int virDomainDiskInsert(virDomainDefPtr def,
|
|||||||
virDomainDiskDefPtr disk);
|
virDomainDiskDefPtr disk);
|
||||||
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
|
void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
|
||||||
virDomainDiskDefPtr disk);
|
virDomainDiskDefPtr disk);
|
||||||
int virDomainDiskDefAssignAddress(virCapsPtr caps, virDomainDiskDefPtr def);
|
int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
|
||||||
|
virDomainDiskDefPtr def);
|
||||||
|
|
||||||
virDomainDiskDefPtr
|
virDomainDiskDefPtr
|
||||||
virDomainDiskRemove(virDomainDefPtr def, size_t i);
|
virDomainDiskRemove(virDomainDefPtr def, size_t i);
|
||||||
|
@ -601,7 +601,6 @@ esxCapsInit(esxPrivate *priv)
|
|||||||
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
|
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
|
||||||
virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");
|
virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr");
|
||||||
|
|
||||||
caps->hasWideScsiBus = true;
|
|
||||||
caps->defaultConsoleTargetType = esxDefaultConsoleType;
|
caps->defaultConsoleTargetType = esxDefaultConsoleType;
|
||||||
|
|
||||||
if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) {
|
if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) {
|
||||||
@ -1100,7 +1099,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(priv->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
|
if (!(priv->xmlopt = virVMXDomainXMLConfInit()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
conn->privateData = priv;
|
conn->privateData = priv;
|
||||||
@ -2786,7 +2785,7 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
|||||||
ctx.formatFileName = NULL;
|
ctx.formatFileName = NULL;
|
||||||
ctx.autodetectSCSIControllerModel = NULL;
|
ctx.autodetectSCSIControllerModel = NULL;
|
||||||
|
|
||||||
def = virVMXParseConfig(&ctx, priv->caps, vmx);
|
def = virVMXParseConfig(&ctx, priv->xmlopt, vmx);
|
||||||
|
|
||||||
if (def != NULL) {
|
if (def != NULL) {
|
||||||
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
|
if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) {
|
||||||
@ -2845,7 +2844,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
|
|||||||
ctx.formatFileName = NULL;
|
ctx.formatFileName = NULL;
|
||||||
ctx.autodetectSCSIControllerModel = NULL;
|
ctx.autodetectSCSIControllerModel = NULL;
|
||||||
|
|
||||||
def = virVMXParseConfig(&ctx, priv->caps, nativeConfig);
|
def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig);
|
||||||
|
|
||||||
if (def != NULL) {
|
if (def != NULL) {
|
||||||
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
|
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
|
||||||
@ -2902,7 +2901,7 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
|
|||||||
ctx.formatFileName = esxFormatVMXFileName;
|
ctx.formatFileName = esxFormatVMXFileName;
|
||||||
ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel;
|
ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel;
|
||||||
|
|
||||||
vmx = virVMXFormatConfig(&ctx, priv->caps, def, virtualHW_version);
|
vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version);
|
||||||
|
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
|
|
||||||
@ -3149,7 +3148,7 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
ctx.formatFileName = esxFormatVMXFileName;
|
ctx.formatFileName = esxFormatVMXFileName;
|
||||||
ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel;
|
ctx.autodetectSCSIControllerModel = esxAutodetectSCSIControllerModel;
|
||||||
|
|
||||||
vmx = virVMXFormatConfig(&ctx, priv->caps, def, virtualHW_version);
|
vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version);
|
||||||
|
|
||||||
if (vmx == NULL) {
|
if (vmx == NULL) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
# vmx/vmx.h
|
# vmx/vmx.h
|
||||||
virVMXConvertToUTF8;
|
virVMXConvertToUTF8;
|
||||||
|
virVMXDomainXMLConfInit;
|
||||||
virVMXEscapeHex;
|
virVMXEscapeHex;
|
||||||
virVMXFormatCDROM;
|
virVMXFormatCDROM;
|
||||||
virVMXFormatConfig;
|
virVMXFormatConfig;
|
||||||
|
@ -7971,7 +7971,7 @@ error:
|
|||||||
* Will fail if not using the 'index' keyword
|
* Will fail if not using the 'index' keyword
|
||||||
*/
|
*/
|
||||||
static virDomainDiskDefPtr
|
static virDomainDiskDefPtr
|
||||||
qemuParseCommandLineDisk(virCapsPtr qemuCaps,
|
qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
|
||||||
const char *val,
|
const char *val,
|
||||||
int nvirtiodisk,
|
int nvirtiodisk,
|
||||||
bool old_style_ceph_args)
|
bool old_style_ceph_args)
|
||||||
@ -8271,7 +8271,7 @@ qemuParseCommandLineDisk(virCapsPtr qemuCaps,
|
|||||||
else
|
else
|
||||||
def->dst[2] = 'a' + idx;
|
def->dst[2] = 'a' + idx;
|
||||||
|
|
||||||
if (virDomainDiskDefAssignAddress(qemuCaps, def) < 0) {
|
if (virDomainDiskDefAssignAddress(xmlopt, def) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("invalid device name '%s'"), def->dst);
|
_("invalid device name '%s'"), def->dst);
|
||||||
virDomainDiskDefFree(def);
|
virDomainDiskDefFree(def);
|
||||||
@ -9345,7 +9345,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
|
|||||||
!disk->dst)
|
!disk->dst)
|
||||||
goto no_memory;
|
goto no_memory;
|
||||||
|
|
||||||
if (virDomainDiskDefAssignAddress(qemuCaps, disk) < 0) {
|
if (virDomainDiskDefAssignAddress(xmlopt, disk) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Cannot assign address for device name '%s'"),
|
_("Cannot assign address for device name '%s'"),
|
||||||
disk->dst);
|
disk->dst);
|
||||||
@ -9571,7 +9571,8 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
|
|||||||
}
|
}
|
||||||
} else if (STREQ(arg, "-drive")) {
|
} else if (STREQ(arg, "-drive")) {
|
||||||
WANT_VALUE();
|
WANT_VALUE();
|
||||||
if (!(disk = qemuParseCommandLineDisk(qemuCaps, val, nvirtiodisk,
|
if (!(disk = qemuParseCommandLineDisk(xmlopt, val,
|
||||||
|
nvirtiodisk,
|
||||||
ceph_args != NULL)))
|
ceph_args != NULL)))
|
||||||
goto error;
|
goto error;
|
||||||
if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0)
|
if (VIR_REALLOC_N(def->disks, def->ndisks+1) < 0)
|
||||||
|
@ -174,7 +174,7 @@ vmwareLoadDomains(struct vmware_driver *driver)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((vmdef =
|
if ((vmdef =
|
||||||
virVMXParseConfig(&ctx, driver->caps, vmx)) == NULL) {
|
virVMXParseConfig(&ctx, driver->xmlopt, vmx)) == NULL) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ vmwareDomainDefineXML(virConnectPtr conn, const char *xml)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* generate vmx file */
|
/* generate vmx file */
|
||||||
vmx = virVMXFormatConfig(&ctx, driver->caps, vmdef, 7);
|
vmx = virVMXFormatConfig(&ctx, driver->xmlopt, vmdef, 7);
|
||||||
if (vmx == NULL)
|
if (vmx == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -601,7 +601,7 @@ vmwareDomainCreateXML(virConnectPtr conn, const char *xml,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* generate vmx file */
|
/* generate vmx file */
|
||||||
vmx = virVMXFormatConfig(&ctx, driver->caps, vmdef, 7);
|
vmx = virVMXFormatConfig(&ctx, driver->xmlopt, vmdef, 7);
|
||||||
if (vmx == NULL)
|
if (vmx == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -943,7 +943,7 @@ vmwareDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
|
|||||||
|
|
||||||
ctx.parseFileName = vmwareCopyVMXFileName;
|
ctx.parseFileName = vmwareCopyVMXFileName;
|
||||||
|
|
||||||
def = virVMXParseConfig(&ctx, driver->caps, nativeConfig);
|
def = virVMXParseConfig(&ctx, driver->xmlopt, nativeConfig);
|
||||||
|
|
||||||
if (def != NULL)
|
if (def != NULL)
|
||||||
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
|
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
|
||||||
|
@ -520,6 +520,18 @@ VIR_ENUM_IMPL(virVMXControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
|
|||||||
* Helpers
|
* Helpers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
virDomainDefParserConfig virVMXDomainDefParserConfig = {
|
||||||
|
.hasWideScsiBus = true,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
virDomainXMLOptionPtr
|
||||||
|
virVMXDomainXMLConfInit(void)
|
||||||
|
{
|
||||||
|
return virDomainXMLOptionNew(&virVMXDomainDefParserConfig,
|
||||||
|
NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
virVMXEscapeHex(const char *string, char escape, const char *special)
|
virVMXEscapeHex(const char *string, char escape, const char *special)
|
||||||
{
|
{
|
||||||
@ -935,7 +947,7 @@ virVMXFloppyDiskNameToUnit(const char *name, int *unit)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virVMXVerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
|
virVMXVerifyDiskAddress(virDomainXMLOptionPtr xmlopt, virDomainDiskDefPtr disk)
|
||||||
{
|
{
|
||||||
virDomainDiskDef def;
|
virDomainDiskDef def;
|
||||||
virDomainDeviceDriveAddressPtr drive;
|
virDomainDeviceDriveAddressPtr drive;
|
||||||
@ -954,7 +966,7 @@ virVMXVerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk)
|
|||||||
def.dst = disk->dst;
|
def.dst = disk->dst;
|
||||||
def.bus = disk->bus;
|
def.bus = disk->bus;
|
||||||
|
|
||||||
if (virDomainDiskDefAssignAddress(caps, &def) < 0) {
|
if (virDomainDiskDefAssignAddress(xmlopt, &def) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Could not verify disk address"));
|
_("Could not verify disk address"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -1211,7 +1223,9 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
virDomainDefPtr
|
virDomainDefPtr
|
||||||
virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
|
virVMXParseConfig(virVMXContext *ctx,
|
||||||
|
virDomainXMLOptionPtr xmlopt,
|
||||||
|
const char *vmx)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
virConfPtr conf = NULL;
|
virConfPtr conf = NULL;
|
||||||
@ -1588,7 +1602,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
|
||||||
VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
|
VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
|
||||||
&def->disks[def->ndisks]) < 0) {
|
&def->disks[def->ndisks]) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1599,7 +1613,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
|
||||||
VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
|
VIR_DOMAIN_DISK_BUS_SCSI, controller, unit,
|
||||||
&def->disks[def->ndisks]) < 0) {
|
&def->disks[def->ndisks]) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1614,7 +1628,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
|
|||||||
/* def:disks (ide) */
|
/* def:disks (ide) */
|
||||||
for (bus = 0; bus < 2; ++bus) {
|
for (bus = 0; bus < 2; ++bus) {
|
||||||
for (unit = 0; unit < 2; ++unit) {
|
for (unit = 0; unit < 2; ++unit) {
|
||||||
if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK,
|
||||||
VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
|
VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
|
||||||
&def->disks[def->ndisks]) < 0) {
|
&def->disks[def->ndisks]) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1625,7 +1639,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM,
|
||||||
VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
|
VIR_DOMAIN_DISK_BUS_IDE, bus, unit,
|
||||||
&def->disks[def->ndisks]) < 0) {
|
&def->disks[def->ndisks]) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1639,7 +1653,7 @@ virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps, const char *vmx)
|
|||||||
|
|
||||||
/* def:disks (floppy) */
|
/* def:disks (floppy) */
|
||||||
for (unit = 0; unit < 2; ++unit) {
|
for (unit = 0; unit < 2; ++unit) {
|
||||||
if (virVMXParseDisk(ctx, caps, conf, VIR_DOMAIN_DISK_DEVICE_FLOPPY,
|
if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_FLOPPY,
|
||||||
VIR_DOMAIN_DISK_BUS_FDC, 0, unit,
|
VIR_DOMAIN_DISK_BUS_FDC, 0, unit,
|
||||||
&def->disks[def->ndisks]) < 0) {
|
&def->disks[def->ndisks]) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1950,7 +1964,7 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
|
virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr conf,
|
||||||
int device, int busType, int controllerOrBus, int unit,
|
int device, int busType, int controllerOrBus, int unit,
|
||||||
virDomainDiskDefPtr *def)
|
virDomainDiskDefPtr *def)
|
||||||
{
|
{
|
||||||
@ -2284,7 +2298,7 @@ virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainDiskDefAssignAddress(caps, *def) < 0) {
|
if (virDomainDiskDefAssignAddress(xmlopt, *def) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Could not assign address to disk '%s'"), (*def)->src);
|
_("Could not assign address to disk '%s'"), (*def)->src);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -3022,7 +3036,7 @@ virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
char *
|
||||||
virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
|
virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDefPtr def,
|
||||||
int virtualHW_version)
|
int virtualHW_version)
|
||||||
{
|
{
|
||||||
char *vmx = NULL;
|
char *vmx = NULL;
|
||||||
@ -3231,7 +3245,7 @@ virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps, virDomainDefPtr def,
|
|||||||
|
|
||||||
/* def:disks */
|
/* def:disks */
|
||||||
for (i = 0; i < def->ndisks; ++i) {
|
for (i = 0; i < def->ndisks; ++i) {
|
||||||
if (virVMXVerifyDiskAddress(caps, def->disks[i]) < 0 ||
|
if (virVMXVerifyDiskAddress(xmlopt, def->disks[i]) < 0 ||
|
||||||
virVMXHandleLegacySCSIDiskDriverName(def, def->disks[i]) < 0) {
|
virVMXHandleLegacySCSIDiskDriverName(def, def->disks[i]) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
typedef struct _virVMXContext virVMXContext;
|
typedef struct _virVMXContext virVMXContext;
|
||||||
|
|
||||||
|
virDomainXMLOptionPtr virVMXDomainXMLConfInit(void);
|
||||||
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
@ -78,7 +79,8 @@ char *virVMXConvertToUTF8(const char *encoding, const char *string);
|
|||||||
* VMX -> Domain XML
|
* VMX -> Domain XML
|
||||||
*/
|
*/
|
||||||
|
|
||||||
virDomainDefPtr virVMXParseConfig(virVMXContext *ctx, virCapsPtr caps,
|
virDomainDefPtr virVMXParseConfig(virVMXContext *ctx,
|
||||||
|
virDomainXMLOptionPtr xmlopt,
|
||||||
const char *vmx);
|
const char *vmx);
|
||||||
|
|
||||||
int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);
|
int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);
|
||||||
@ -86,9 +88,9 @@ int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);
|
|||||||
int virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
|
int virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
|
||||||
int *virtualDev);
|
int *virtualDev);
|
||||||
|
|
||||||
int virVMXParseDisk(virVMXContext *ctx, virCapsPtr caps, virConfPtr conf,
|
int virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
|
||||||
int device, int busType, int controllerOrBus, int unit,
|
virConfPtr conf, int device, int busType,
|
||||||
virDomainDiskDefPtr *def);
|
int controllerOrBus, int unit, virDomainDiskDefPtr *def);
|
||||||
|
|
||||||
int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def);
|
int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def);
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ int virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def);
|
|||||||
* Domain XML -> VMX
|
* Domain XML -> VMX
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *virVMXFormatConfig(virVMXContext *ctx, virCapsPtr caps,
|
char *virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
|
||||||
virDomainDefPtr def, int virtualHW_version);
|
virDomainDefPtr def, int virtualHW_version);
|
||||||
|
|
||||||
int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer);
|
int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# include "vmx/vmx.h"
|
# include "vmx/vmx.h"
|
||||||
|
|
||||||
static virCapsPtr caps;
|
static virCapsPtr caps;
|
||||||
|
static virDomainXMLOptionPtr xmlopt;
|
||||||
static virVMXContext ctx;
|
static virVMXContext ctx;
|
||||||
|
|
||||||
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
|
static int testDefaultConsoleType(const char *ostype ATTRIBUTE_UNUSED,
|
||||||
@ -36,8 +37,6 @@ testCapsInit(void)
|
|||||||
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
|
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
|
||||||
virCapabilitiesAddHostMigrateTransport(caps, "esx");
|
virCapabilitiesAddHostMigrateTransport(caps, "esx");
|
||||||
|
|
||||||
caps->hasWideScsiBus = true;
|
|
||||||
|
|
||||||
/* i686 guest */
|
/* i686 guest */
|
||||||
guest =
|
guest =
|
||||||
virCapabilitiesAddGuest(caps, "hvm",
|
virCapabilitiesAddGuest(caps, "hvm",
|
||||||
@ -93,7 +92,7 @@ testCompareFiles(const char *vmx, const char *xml)
|
|||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
def = virVMXParseConfig(&ctx, caps, vmxData);
|
def = virVMXParseConfig(&ctx, xmlopt, vmxData);
|
||||||
|
|
||||||
if (def == NULL) {
|
if (def == NULL) {
|
||||||
err = virGetLastError();
|
err = virGetLastError();
|
||||||
@ -221,6 +220,9 @@ mymain(void)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(xmlopt = virVMXDomainXMLConfInit()))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
ctx.opaque = NULL;
|
ctx.opaque = NULL;
|
||||||
ctx.parseFileName = testParseVMXFileName;
|
ctx.parseFileName = testParseVMXFileName;
|
||||||
ctx.formatFileName = NULL;
|
ctx.formatFileName = NULL;
|
||||||
@ -296,6 +298,7 @@ mymain(void)
|
|||||||
DO_TEST("svga", "svga");
|
DO_TEST("svga", "svga");
|
||||||
|
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
|
virObjectUnref(xmlopt);
|
||||||
|
|
||||||
return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,6 @@ testCapsInit(void)
|
|||||||
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
|
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
|
||||||
virCapabilitiesAddHostMigrateTransport(caps, "esx");
|
virCapabilitiesAddHostMigrateTransport(caps, "esx");
|
||||||
|
|
||||||
caps->hasWideScsiBus = true;
|
|
||||||
|
|
||||||
/* i686 guest */
|
/* i686 guest */
|
||||||
guest =
|
guest =
|
||||||
@ -102,7 +101,7 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version)
|
|||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
formatted = virVMXFormatConfig(&ctx, caps, def, virtualHW_version);
|
formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version);
|
||||||
|
|
||||||
if (formatted == NULL) {
|
if (formatted == NULL) {
|
||||||
goto failure;
|
goto failure;
|
||||||
@ -240,7 +239,7 @@ mymain(void)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)))
|
if (!(xmlopt = virVMXDomainXMLConfInit()))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
ctx.opaque = NULL;
|
ctx.opaque = NULL;
|
||||||
@ -312,6 +311,7 @@ mymain(void)
|
|||||||
DO_TEST("svga", "svga", 4);
|
DO_TEST("svga", "svga", 4);
|
||||||
|
|
||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
|
virObjectUnref(xmlopt);
|
||||||
|
|
||||||
return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user