mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
vmx: convert any amount of NICs
Scan the parsed VMX file, and gather the biggest index of the network interfaces there: this way, it is possible to parse all the available network interfaces, instead of just 4 maximum. Add the VMX file attached to RHBZ#1560917 as testcase esx-in-the-wild-8. https://bugzilla.redhat.com/show_bug.cgi?id=1560917 Signed-off-by: Pino Toscano <ptoscano@redhat.com>
This commit is contained in:
parent
e508e04b10
commit
5c744a2d44
@ -1286,6 +1286,36 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def,
|
||||
return result;
|
||||
}
|
||||
|
||||
struct virVMXConfigScanResults {
|
||||
int networks_max_index;
|
||||
};
|
||||
|
||||
static int
|
||||
virVMXConfigScanResultsCollector(const char* name,
|
||||
virConfValuePtr value ATTRIBUTE_UNUSED,
|
||||
void *opaque)
|
||||
{
|
||||
struct virVMXConfigScanResults *results = opaque;
|
||||
|
||||
if (STRCASEPREFIX(name, "ethernet")) {
|
||||
unsigned int idx;
|
||||
char *p;
|
||||
|
||||
if (virStrToLong_uip(name + 8, &p, 10, &idx) < 0 ||
|
||||
*p != '.') {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("failed to parse the index of the VMX key '%s'"),
|
||||
name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((int) idx > results->networks_max_index)
|
||||
results->networks_max_index = (int) idx;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
@ -1322,6 +1352,7 @@ virVMXParseConfig(virVMXContext *ctx,
|
||||
bool hgfs_disabled = true;
|
||||
long long sharedFolder_maxNum = 0;
|
||||
int cpumasklen;
|
||||
struct virVMXConfigScanResults results = { -1 };
|
||||
|
||||
if (ctx->parseFileName == NULL) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
@ -1357,6 +1388,9 @@ virVMXParseConfig(virVMXContext *ctx,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virConfWalk(conf, virVMXConfigScanResultsCollector, &results) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Allocate domain def */
|
||||
if (!(def = virDomainDefNew()))
|
||||
goto cleanup;
|
||||
@ -1751,7 +1785,7 @@ virVMXParseConfig(virVMXContext *ctx,
|
||||
}
|
||||
|
||||
/* def:nets */
|
||||
for (controller = 0; controller < 4; ++controller) {
|
||||
for (controller = 0; controller <= results.networks_max_index; ++controller) {
|
||||
virDomainNetDefPtr net = NULL;
|
||||
if (virVMXParseEthernet(conf, controller, &net) < 0)
|
||||
goto cleanup;
|
||||
@ -2539,13 +2573,6 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (controller < 0 || controller > 3) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Ethernet controller index %d out of [0..3] range"),
|
||||
controller);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
|
||||
|
||||
VMX_BUILD_NAME(present);
|
||||
|
163
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.vmx
Normal file
163
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.vmx
Normal file
@ -0,0 +1,163 @@
|
||||
.encoding = "UTF-8"
|
||||
config.version = "8"
|
||||
virtualHW.version = "11"
|
||||
vmci0.present = "TRUE"
|
||||
svga.vramSize = "8388608"
|
||||
memSize = "2048"
|
||||
sched.cpu.units = "mhz"
|
||||
tools.upgrade.policy = "manual"
|
||||
scsi0.virtualDev = "pvscsi"
|
||||
scsi0.present = "TRUE"
|
||||
sata0.present = "TRUE"
|
||||
sata0:0.deviceType = "cdrom-image"
|
||||
sata0:0.fileName = "/vmfs/volumes/692eb778-2d4937fe/CentOS-4.7.ServerCD-x86_64.iso"
|
||||
sata0:0.present = "TRUE"
|
||||
scsi0:0.deviceType = "scsi-hardDisk"
|
||||
scsi0:0.fileName = "RHEL7_6.vmdk"
|
||||
sched.scsi0:0.shares = "normal"
|
||||
scsi0:0.present = "TRUE"
|
||||
floppy0.startConnected = "FALSE"
|
||||
floppy0.clientDevice = "TRUE"
|
||||
floppy0.fileName = "vmware-null-remote-floppy"
|
||||
ethernet0.virtualDev = "vmxnet3"
|
||||
ethernet0.networkName = "VM Network"
|
||||
ethernet0.addressType = "static"
|
||||
ethernet0.address = "00:1a:4a:16:01:55"
|
||||
ethernet0.present = "TRUE"
|
||||
displayName = "RHEL7_10_NICs"
|
||||
guestOS = "rhel7-64"
|
||||
toolScripts.afterPowerOn = "TRUE"
|
||||
toolScripts.afterResume = "TRUE"
|
||||
toolScripts.beforeSuspend = "TRUE"
|
||||
toolScripts.beforePowerOff = "TRUE"
|
||||
tools.syncTime = "FALSE"
|
||||
messageBus.tunnelEnabled = "FALSE"
|
||||
uuid.bios = "42 35 94 20 99 dc 42 61-52 64 ba 58 dd ae 20 e4"
|
||||
vc.uuid = "50 35 1d e6 7d 56 29 ab-9d 72 c7 f9 ea 3f cf d0"
|
||||
sched.cpu.latencySensitivity = "normal"
|
||||
tools.guest.desktop.autolock = "FALSE"
|
||||
nvram = "RHEL7_6.nvram"
|
||||
pciBridge0.present = "TRUE"
|
||||
svga.present = "TRUE"
|
||||
pciBridge4.present = "TRUE"
|
||||
pciBridge4.virtualDev = "pcieRootPort"
|
||||
pciBridge4.functions = "8"
|
||||
pciBridge5.present = "TRUE"
|
||||
pciBridge5.virtualDev = "pcieRootPort"
|
||||
pciBridge5.functions = "8"
|
||||
pciBridge6.present = "TRUE"
|
||||
pciBridge6.virtualDev = "pcieRootPort"
|
||||
pciBridge6.functions = "8"
|
||||
pciBridge7.present = "TRUE"
|
||||
pciBridge7.virtualDev = "pcieRootPort"
|
||||
pciBridge7.functions = "8"
|
||||
hpet0.present = "true"
|
||||
sched.scsi0:0.throughputCap = "off"
|
||||
ethernet0.uptCompatibility = "TRUE"
|
||||
ethernet0.pciSlotNumber = "192"
|
||||
monitor.phys_bits_used = "42"
|
||||
pciBridge0.pciSlotNumber = "17"
|
||||
pciBridge4.pciSlotNumber = "21"
|
||||
pciBridge5.pciSlotNumber = "22"
|
||||
pciBridge6.pciSlotNumber = "23"
|
||||
pciBridge7.pciSlotNumber = "24"
|
||||
replay.supported = "false"
|
||||
sata0.pciSlotNumber = "33"
|
||||
scsi0.pciSlotNumber = "160"
|
||||
scsi0.sasWWID = "50 05 05 60 99 dc 42 60"
|
||||
softPowerOff = "FALSE"
|
||||
virtualHW.productCompatibility = "hosted"
|
||||
vmci0.pciSlotNumber = "32"
|
||||
vmotion.checkpointFBSize = "8388608"
|
||||
vmotion.checkpointSVGAPrimarySize = "8388608"
|
||||
tools.remindInstall = "FALSE"
|
||||
toolsInstallManager.lastInstallError = "0"
|
||||
toolsInstallManager.updateCounter = "1"
|
||||
migrate.hostlog = "RHEL7_6-2a23b979.hlog"
|
||||
sched.cpu.min = "0"
|
||||
sched.cpu.shares = "normal"
|
||||
sched.mem.min = "0"
|
||||
sched.mem.minSize = "0"
|
||||
sched.mem.shares = "normal"
|
||||
scsi0:1.deviceType = "scsi-hardDisk"
|
||||
scsi0:1.fileName = "RHEL7_6_1.vmdk"
|
||||
scsi0:1.mode = "independent-nonpersistent"
|
||||
sched.scsi0:1.shares = "normal"
|
||||
sched.scsi0:1.throughputCap = "off"
|
||||
scsi0:1.present = "TRUE"
|
||||
scsi0:2.deviceType = "scsi-hardDisk"
|
||||
scsi0:2.fileName = "/vmfs/volumes/5669422e-699d77db-c144-00e0815e303e/block4/block4.vmdk"
|
||||
sched.scsi0:2.shares = "normal"
|
||||
sched.scsi0:2.throughputCap = "off"
|
||||
scsi0:2.present = "TRUE"
|
||||
numvcpus = "8"
|
||||
cpuid.coresPerSocket = "2"
|
||||
sched.swap.derivedName = "/vmfs/volumes/29dcc8ec-e8d62d3b-0000-000000000000/RHEL7_6/RHEL7_6-05efff7d.vswp"
|
||||
uuid.location = "56 4d d9 db b7 4e df ce-58 6a 77 56 82 53 aa 18"
|
||||
replay.filename = ""
|
||||
scsi0:2.redo = ""
|
||||
scsi0:1.redo = ""
|
||||
scsi0:0.redo = ""
|
||||
vmci0.id = "-575790876"
|
||||
cleanShutdown = "TRUE"
|
||||
ethernet1.virtualDev = "e1000"
|
||||
ethernet1.networkName = "VM Network"
|
||||
ethernet1.addressType = "vpx"
|
||||
ethernet1.generatedAddress = "00:1a:4a:16:21:85"
|
||||
ethernet1.present = "TRUE"
|
||||
ethernet2.virtualDev = "e1000e"
|
||||
ethernet2.networkName = "VM Network"
|
||||
ethernet2.addressType = "vpx"
|
||||
ethernet2.generatedAddress = "00:1a:4a:16:21:82"
|
||||
ethernet2.present = "TRUE"
|
||||
ethernet3.virtualDev = "vmxnet3"
|
||||
ethernet3.networkName = "VM Network"
|
||||
ethernet3.addressType = "vpx"
|
||||
ethernet3.generatedAddress = "00:1a:4a:16:21:69"
|
||||
ethernet3.uptCompatibility = "TRUE"
|
||||
ethernet3.present = "TRUE"
|
||||
ethernet4.virtualDev = "vmxnet3"
|
||||
ethernet4.networkName = "VM Network"
|
||||
ethernet4.addressType = "vpx"
|
||||
ethernet4.generatedAddress = "00:1a:4a:16:21:80"
|
||||
ethernet4.uptCompatibility = "TRUE"
|
||||
ethernet4.present = "TRUE"
|
||||
ethernet5.virtualDev = "vmxnet3"
|
||||
ethernet5.networkName = "VM Network"
|
||||
ethernet5.addressType = "vpx"
|
||||
ethernet5.generatedAddress = "00:1a:4a:16:21:a3"
|
||||
ethernet5.uptCompatibility = "TRUE"
|
||||
ethernet5.present = "TRUE"
|
||||
ethernet6.virtualDev = "vmxnet3"
|
||||
ethernet6.networkName = "VM Network"
|
||||
ethernet6.addressType = "vpx"
|
||||
ethernet6.generatedAddress = "00:1a:4a:16:21:a8"
|
||||
ethernet6.uptCompatibility = "TRUE"
|
||||
ethernet6.present = "TRUE"
|
||||
ethernet7.virtualDev = "vmxnet3"
|
||||
ethernet7.networkName = "VM Network"
|
||||
ethernet7.addressType = "vpx"
|
||||
ethernet7.generatedAddress = "00:1a:4a:16:21:a9"
|
||||
ethernet7.uptCompatibility = "TRUE"
|
||||
ethernet7.present = "TRUE"
|
||||
ethernet8.virtualDev = "vmxnet3"
|
||||
ethernet8.networkName = "VM Network"
|
||||
ethernet8.addressType = "vpx"
|
||||
ethernet8.generatedAddress = "00:1a:4a:16:21:78"
|
||||
ethernet8.uptCompatibility = "TRUE"
|
||||
ethernet8.present = "TRUE"
|
||||
ethernet9.virtualDev = "vmxnet3"
|
||||
ethernet9.networkName = "VM Network"
|
||||
ethernet9.addressType = "vpx"
|
||||
ethernet9.generatedAddress = "00:1a:4a:16:21:81"
|
||||
ethernet9.uptCompatibility = "TRUE"
|
||||
ethernet9.present = "TRUE"
|
||||
ethernet1.pciSlotNumber = "34"
|
||||
ethernet2.pciSlotNumber = "224"
|
||||
ethernet3.pciSlotNumber = "256"
|
||||
ethernet4.pciSlotNumber = "1184"
|
||||
ethernet5.pciSlotNumber = "1216"
|
||||
ethernet6.pciSlotNumber = "1248"
|
||||
ethernet7.pciSlotNumber = "1280"
|
||||
ethernet8.pciSlotNumber = "2208"
|
||||
ethernet9.pciSlotNumber = "2240"
|
89
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml
Normal file
89
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<domain type='vmware'>
|
||||
<name>RHEL7_10_NICs</name>
|
||||
<uuid>42359420-99dc-4261-5264-ba58ddae20e4</uuid>
|
||||
<memory unit='KiB'>2097152</memory>
|
||||
<currentMemory unit='KiB'>2097152</currentMemory>
|
||||
<vcpu placement='static'>8</vcpu>
|
||||
<cputune>
|
||||
<shares>8000</shares>
|
||||
</cputune>
|
||||
<os>
|
||||
<type arch='x86_64'>hvm</type>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<devices>
|
||||
<disk type='file' device='disk'>
|
||||
<source file='[datastore] directory/RHEL7_6.vmdk'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||
</disk>
|
||||
<disk type='file' device='disk'>
|
||||
<source file='[datastore] directory/RHEL7_6_1.vmdk'/>
|
||||
<target dev='sdb' bus='scsi'/>
|
||||
<transient/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='1'/>
|
||||
</disk>
|
||||
<disk type='file' device='disk'>
|
||||
<source file='[5669422e-699d77db-c144-00e0815e303e] block4/block4.vmdk'/>
|
||||
<target dev='sdc' bus='scsi'/>
|
||||
<address type='drive' controller='0' bus='0' target='0' unit='2'/>
|
||||
</disk>
|
||||
<controller type='scsi' index='0' model='vmpvscsi'/>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:01:55'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='vmxnet3'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:85'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='e1000'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:82'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='e1000e'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:69'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='vmxnet3'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:80'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='vmxnet3'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:a3'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='vmxnet3'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:a8'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='vmxnet3'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:a9'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='vmxnet3'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:78'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='vmxnet3'/>
|
||||
</interface>
|
||||
<interface type='bridge'>
|
||||
<mac address='00:1a:4a:16:21:81'/>
|
||||
<source bridge='VM Network'/>
|
||||
<model type='vmxnet3'/>
|
||||
</interface>
|
||||
<video>
|
||||
<model type='vmvga' vram='8192' primary='yes'/>
|
||||
</video>
|
||||
</devices>
|
||||
</domain>
|
@ -268,6 +268,7 @@ mymain(void)
|
||||
DO_TEST("esx-in-the-wild-5", "esx-in-the-wild-5");
|
||||
DO_TEST("esx-in-the-wild-6", "esx-in-the-wild-6");
|
||||
DO_TEST("esx-in-the-wild-7", "esx-in-the-wild-7");
|
||||
DO_TEST("esx-in-the-wild-8", "esx-in-the-wild-8");
|
||||
|
||||
DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1");
|
||||
DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2");
|
||||
|
Loading…
Reference in New Issue
Block a user