esx: Add support for the controller element

Also don't abuse the disk driver name to specify the SCSI controller
model anymore:

  <driver name='buslogic'/>

Use the newly added model attribute of the controller element for this:

  <controller type='scsi' index='0' model='buslogic'/>

The disk driver name approach is deprecated now, but still works for
backward compatibility reasons.

Update the documentation and tests accordingly.

Fix usage of the words controller and id in the VMX handling code. Use
controller, bus and unit properly.
This commit is contained in:
Matthias Bolte 2010-06-17 19:57:12 +02:00
parent c391291244
commit d72d92565b
26 changed files with 561 additions and 226 deletions

View File

@ -308,6 +308,21 @@ ethernet0.checkMACAddress = "false"
<p>
Here a domain XML snippet:
</p>
<pre>
...
&lt;disk type='file' device='disk'&gt;
&lt;source file='[local-storage] Fedora11/Fedora11.vmdk'/&gt;
&lt;target dev='sda' bus='scsi'/&gt;
&lt;address type='drive' controller='0' bus='0' unit='0'/&gt;
&lt;/disk&gt;
&lt;controller type='scsi' index='0' model='<strong>lsilogic</strong>'/&gt;
...
</pre>
<p>
The controller element is supported <span class="since">since 0.8.2</span>.
Prior to this <code>&lt;driver name='lsilogic'/&gt;</code> was abused to
specify the SCSI controller model. This attribute usage is deprecated now.
</p>
<pre>
...
&lt;disk type='file' device='disk'&gt;
@ -393,7 +408,7 @@ ide0:0.startConnected = "false"
ethernet0.present = "true"
ethernet0.networkName = "VM Network"
ethernet0.addressType = "vpx"
ethernet0.address = "00:50:56:91:48:c7"
ethernet0.generatedAddress = "00:50:56:91:48:c7"
chipset.onlineStandby = "false"
guestOSAltName = "Red Hat Enterprise Linux 5 (32-Bit)"
guestOS = "rhel5"
@ -434,10 +449,11 @@ Enter root password for example.com:
&lt;on_crash&gt;destroy&lt;/on_crash&gt;
&lt;devices&gt;
&lt;disk type='file' device='disk'&gt;
&lt;driver name='lsilogic'/&gt;
&lt;source file='[local-storage] Fedora11/Fedora11.vmdk'/&gt;
&lt;target dev='sda' bus='scsi'/&gt;
&lt;address type='drive' controller='0' bus='0' unit='0'/&gt;
&lt;/disk&gt;
&lt;controller type='scsi' index='0' model='lsilogic'/&gt;
&lt;interface type='bridge'&gt;
&lt;mac address='00:50:56:91:48:c7'/&gt;
&lt;source bridge='VM Network'/&gt;
@ -465,10 +481,11 @@ $ cat &gt; demo.xml &lt;&lt; EOF
&lt;/os&gt;
&lt;devices&gt;
&lt;disk type='file' device='disk'&gt;
&lt;driver name='lsilogic'/&gt;
&lt;source file='[local-storage] Fedora11/Fedora11.vmdk'/&gt;
&lt;target dev='sda' bus='scsi'/&gt;
&lt;address type='drive' controller='0' bus='0' unit='0'/&gt;
&lt;/disk&gt;
&lt;controller type='scsi' index='0' model='lsilogic'/&gt;
&lt;interface type='bridge'&gt;
&lt;mac address='00:50:56:25:48:c7'/&gt;
&lt;source bridge='VM Network'/&gt;
@ -517,7 +534,9 @@ ethernet0.address = "00:50:56:25:48:C7"
&lt;disk type='file' device='disk'&gt;
&lt;source file='[local-storage] Fedora11/Fedora11.vmdk'/&gt;
&lt;target dev='sda' bus='scsi'/&gt;
&lt;address type='drive' controller='0' bus='0' unit='0'/&gt;
&lt;/disk&gt;
&lt;controller type='scsi' index='0'/&gt;
&lt;interface type='bridge'&gt;
&lt;mac address='00:50:56:25:48:c7'/&gt;
&lt;source bridge='VM Network'/&gt;

View File

@ -2153,8 +2153,8 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
goto cleanup;
}
def = esxVMX_ParseConfig(priv->host, vmx, datastoreName, directoryName,
priv->host->productVersion);
def = esxVMX_ParseConfig(priv->host, priv->caps, vmx, datastoreName,
directoryName, priv->host->productVersion);
if (def != NULL) {
xml = virDomainDefFormat(def, flags);
@ -2194,7 +2194,7 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
return NULL;
}
def = esxVMX_ParseConfig(priv->host, nativeConfig, "?", "?",
def = esxVMX_ParseConfig(priv->host, priv->caps, nativeConfig, "?", "?",
priv->host->productVersion);
if (def != NULL) {
@ -2229,7 +2229,8 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
return NULL;
}
vmx = esxVMX_FormatConfig(priv->host, def, priv->host->productVersion);
vmx = esxVMX_FormatConfig(priv->host, priv->caps, def,
priv->host->productVersion);
virDomainDefFree(def);
@ -2457,7 +2458,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED)
}
/* Build VMX from domain XML */
vmx = esxVMX_FormatConfig(priv->host, def, priv->host->productVersion);
vmx = esxVMX_FormatConfig(priv->host, priv->caps, def,
priv->host->productVersion);
if (vmx == NULL) {
goto cleanup;

File diff suppressed because it is too large Load Diff

View File

@ -29,17 +29,25 @@
# include "esx_vi.h"
int
esxVMX_SCSIDiskNameToControllerAndID(const char *name, int *controller, int *id);
esxVMX_SCSIDiskNameToControllerAndUnit(const char *name, int *controller,
int *unit);
int
esxVMX_IDEDiskNameToControllerAndID(const char *name, int *controller, int *id);
esxVMX_IDEDiskNameToBusAndUnit(const char *name, int *bus, int *unit);
int
esxVMX_FloppyDiskNameToController(const char *name, int *controller);
esxVMX_FloppyDiskNameToUnit(const char *name, int *unit);
int
esxVMX_GatherSCSIControllers(virDomainDefPtr conf, char *virtualDev[4],
int present[4]);
esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk);
int
esxVMX_HandleLegacySCSIDiskDriverName(virDomainDefPtr def,
virDomainDiskDefPtr disk);
int
esxVMX_GatherSCSIControllers(virDomainDefPtr def, int virtualDev[4],
bool present[4]);
char *
esxVMX_AbsolutePathToDatastoreRelatedPath(esxVI_Context *ctx,
@ -56,7 +64,7 @@ esxVMX_ParseFileName(esxVI_Context *ctx, const char *fileName,
const char *datastoreName, const char *directoryName);
virDomainDefPtr
esxVMX_ParseConfig(esxVI_Context *ctx, const char *vmx,
esxVMX_ParseConfig(esxVI_Context *ctx, virCapsPtr caps, const char *vmx,
const char *datastoreName, const char *directoryName,
esxVI_ProductVersion productVersion);
@ -65,11 +73,11 @@ esxVMX_ParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);
int
esxVMX_ParseSCSIController(virConfPtr conf, int controller, int *present,
char **virtualDev);
int *virtualDev);
int
esxVMX_ParseDisk(esxVI_Context *ctx, virConfPtr conf, int device, int bus,
int controller, int id, const char *virtualDev,
esxVMX_ParseDisk(esxVI_Context *ctx, virCapsPtr caps, virConfPtr conf,
int device, int busType, int controllerOrBus, int unit,
const char *datastoreName, const char *directoryName,
virDomainDiskDefPtr *def);
int
@ -95,7 +103,7 @@ char *
esxVMX_FormatFileName(esxVI_Context *ctx, const char *src);
char *
esxVMX_FormatConfig(esxVI_Context *ctx, virDomainDefPtr def,
esxVMX_FormatConfig(esxVI_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
esxVI_ProductVersion productVersion);
int

View File

@ -13,10 +13,11 @@
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='LSILOGIC'/>
<source file='[datastore] directory/FEDORA11.VMDK'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='lsilogic'/>
<interface type='bridge'>
<mac address='00:50:56:91:48:c7'/>
<source bridge='VM NETWORK'/>

View File

@ -13,10 +13,11 @@
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='lsilogic'/>
<source file='[datastore] directory/fedora11.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='lsilogic'/>
<interface type='bridge'>
<mac address='00:50:56:91:48:c7'/>
<source bridge='vm network'/>

View File

@ -14,6 +14,8 @@
<disk type='block' device='cdrom'>
<source dev='/dev/scd0'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
</devices>
</domain>

View File

@ -14,6 +14,8 @@
<disk type='file' device='cdrom'>
<source file='[datastore] directory/cdrom.iso'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
</devices>
</domain>

View File

@ -14,6 +14,8 @@
<disk type='block' device='cdrom'>
<source dev='/dev/scd0'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0'/>
</devices>
</domain>

View File

@ -14,6 +14,8 @@
<disk type='file' device='cdrom'>
<source file='[datastore] directory/cdrom.iso'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0'/>
</devices>
</domain>

View File

@ -13,10 +13,11 @@
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='lsilogic'/>
<source file='[datastore] directory/Fedora11.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='lsilogic'/>
<interface type='bridge'>
<mac address='00:50:56:91:48:c7'/>
<source bridge='VM Network'/>

View File

@ -13,31 +13,40 @@
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='lsilogic' cache='writethrough'/>
<driver cache='writethrough'/>
<source file='[datastore] directory/Debian1.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='buslogic'/>
<source file='[datastore] directory/Debian1-cdrom.iso'/>
<target dev='sdp' bus='scsi'/>
<address type='drive' controller='1' bus='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<source file='/vmimages/tools-isoimages/linux.iso'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='block' device='cdrom'>
<source dev='/dev/scd0'/>
<target dev='hdb' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='1'/>
</disk>
<disk type='file' device='disk'>
<source file='[datastore] directory/Debian1-IDE.vmdk'/>
<target dev='hdd' bus='ide'/>
<address type='drive' controller='0' bus='1' unit='1'/>
</disk>
<disk type='block' device='floppy'>
<source dev='/dev/fd0'/>
<target dev='fda' bus='fdc'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='lsilogic'/>
<controller type='scsi' index='1' model='buslogic'/>
<controller type='fdc' index='0'/>
<controller type='ide' index='0'/>
<interface type='bridge'>
<mac address='00:0c:29:3c:98:3e'/>
<source bridge='VM Network'/>

View File

@ -13,18 +13,23 @@
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='lsilogic'/>
<source file='[datastore] directory/Debian2.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='file' device='cdrom'>
<source file='[498076b2-02796c1a-ef5b-000ae484a6a3] Isos/debian-testing-amd64-netinst.iso'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='file' device='floppy'>
<source file='[498076b2-02796c1a-ef5b-000ae484a6a3] Debian2/dummy.flp'/>
<target dev='fdb' bus='fdc'/>
<address type='drive' controller='0' bus='0' unit='1'/>
</disk>
<controller type='scsi' index='0' model='lsilogic'/>
<controller type='fdc' index='0'/>
<controller type='ide' index='0'/>
<interface type='bridge'>
<mac address='00:0c:29:f5:c3:0c'/>
<source bridge='VM Network'/>

View File

@ -13,10 +13,11 @@
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='lsilogic'/>
<source file='[datastore] directory/virtMonServ1.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='lsilogic'/>
<interface type='bridge'>
<mac address='00:50:56:91:66:d4'/>
<source bridge='VM Network'/>

View File

@ -14,6 +14,8 @@
<disk type='block' device='floppy'>
<source dev='/dev/fd0'/>
<target dev='fda' bus='fdc'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='fdc' index='0'/>
</devices>
</domain>

View File

@ -14,6 +14,8 @@
<disk type='file' device='floppy'>
<source file='[datastore] directory/floppy.flp'/>
<target dev='fda' bus='fdc'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='fdc' index='0'/>
</devices>
</domain>

View File

@ -15,7 +15,9 @@
<disk type='file' device='disk'>
<source file='[datastore] directory/Debian-System1-0-cl2.vmdk'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
<interface type='bridge'>
<mac address='00:0c:29:d6:2b:d3'/>
<source bridge='net1'/>

View File

@ -15,7 +15,9 @@
<disk type='file' device='disk'>
<source file='[datastore] directory/Debian-System1-0-cl3.vmdk'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
<interface type='bridge'>
<mac address='00:0c:29:d6:cb:a4'/>
<source bridge='net1'/>

View File

@ -15,7 +15,9 @@
<disk type='file' device='disk'>
<source file='[datastore] directory/Debian-System1-0-cl1.vmdk'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
<interface type='bridge'>
<mac address='00:0c:29:c4:be:5a'/>
<source bridge='net1'/>

View File

@ -15,7 +15,9 @@
<disk type='file' device='disk'>
<source file='[datastore] directory/Debian-System1-0-cl2.vmdk'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
<interface type='bridge'>
<mac address='00:0c:29:c5:e3:5d'/>
<source bridge='net2'/>

View File

@ -14,6 +14,8 @@
<disk type='file' device='disk'>
<source file='[datastore] directory/harddisk.vmdk'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='ide' index='0'/>
</devices>
</domain>

View File

@ -14,6 +14,8 @@
<disk type='file' device='disk'>
<source file='[datastore] directory/harddisk.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0'/>
</devices>
</domain>

View File

@ -12,19 +12,22 @@
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='buslogic'/>
<source file='[datastore] directory/harddisk1.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<disk type='file' device='disk'>
<driver name='lsilogic'/>
<source file='[datastore] directory/harddisk2.vmdk'/>
<target dev='sdp' bus='scsi'/>
<address type='drive' controller='1' bus='0' unit='0'/>
</disk>
<disk type='file' device='disk'>
<driver name='lsisas1068'/>
<source file='[datastore] directory/harddisk3.vmdk'/>
<target dev='sdae' bus='scsi'/>
<address type='drive' controller='2' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='buslogic'/>
<controller type='scsi' index='1' model='lsilogic'/>
<controller type='scsi' index='2' model='lsisas1068'/>
</devices>
</domain>

View File

@ -12,9 +12,11 @@
<on_crash>destroy</on_crash>
<devices>
<disk type='file' device='disk'>
<driver name='buslogic' cache='writethrough'/>
<driver cache='writethrough'/>
<source file='[datastore] directory/harddisk.vmdk'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' unit='0'/>
</disk>
<controller type='scsi' index='0' model='buslogic'/>
</devices>
</domain>

View File

@ -13,9 +13,59 @@
static char *progname = NULL;
static char *abs_srcdir = NULL;
static virCapsPtr caps = NULL;
# define MAX_FILE 4096
static void
testCapsInit(void)
{
virCapsGuestPtr guest = NULL;
caps = virCapabilitiesNew("i686", 1, 1);
if (caps == NULL) {
return;
}
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
virCapabilitiesAddHostMigrateTransport(caps, "esx");
caps->hasWideScsiBus = true;
/* i686 guest */
guest =
virCapabilitiesAddGuest(caps, "hvm", "i686", 32, NULL, NULL, 0, NULL);
if (guest == NULL) {
goto failure;
}
if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL) == NULL) {
goto failure;
}
/* x86_64 guest */
guest =
virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64, NULL, NULL, 0, NULL);
if (guest == NULL) {
goto failure;
}
if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0,
NULL) == NULL) {
goto failure;
}
return;
failure:
virCapabilitiesFree(caps);
caps = NULL;
}
static int
testCompareFiles(const char *vmx, const char *xml,
esxVI_ProductVersion productVersion)
@ -37,7 +87,7 @@ testCompareFiles(const char *vmx, const char *xml,
goto failure;
}
def = esxVMX_ParseConfig(NULL, vmxData, "datastore", "directory",
def = esxVMX_ParseConfig(NULL, caps, vmxData, "datastore", "directory",
productVersion);
if (def == NULL) {
@ -123,6 +173,12 @@ mymain(int argc, char **argv)
} \
} while (0)
testCapsInit();
if (caps == NULL) {
return EXIT_FAILURE;
}
DO_TEST("case-insensitive-1", "case-insensitive-1", esxVI_ProductVersion_ESX35);
DO_TEST("case-insensitive-2", "case-insensitive-2", esxVI_ProductVersion_ESX35);
@ -176,6 +232,8 @@ mymain(int argc, char **argv)
DO_TEST("gsx-in-the-wild-3", "gsx-in-the-wild-3", esxVI_ProductVersion_ESX35);
DO_TEST("gsx-in-the-wild-4", "gsx-in-the-wild-4", esxVI_ProductVersion_ESX35);
virCapabilitiesFree(caps);
return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}

View File

@ -18,7 +18,7 @@ static virCapsPtr caps = NULL;
# define MAX_FILE 4096
static void
testESXCapsInit(void)
testCapsInit(void)
{
virCapsGuestPtr guest = NULL;
@ -28,9 +28,11 @@ testESXCapsInit(void)
return;
}
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x50, 0x56 });
virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
virCapabilitiesAddHostMigrateTransport(caps, "esx");
caps->hasWideScsiBus = true;
/* i686 guest */
guest =
virCapabilitiesAddGuest(caps, "hvm", "i686", 32, NULL, NULL, 0, NULL);
@ -90,7 +92,7 @@ testCompareFiles(const char *xml, const char *vmx,
goto failure;
}
formatted = esxVMX_FormatConfig(NULL, def, productVersion);
formatted = esxVMX_FormatConfig(NULL, caps, def, productVersion);
if (formatted == NULL) {
goto failure;
@ -165,7 +167,7 @@ mymain(int argc, char **argv)
} \
} while (0)
testESXCapsInit();
testCapsInit();
if (caps == NULL) {
return EXIT_FAILURE;