From 2b89f1d8f513152e03bf82ff9560988da1ea79fb Mon Sep 17 00:00:00 2001 From: Dawid Zamirski Date: Mon, 23 May 2016 17:22:53 -0400 Subject: [PATCH] esx: add pciBridge devices when SCSI is used When a SCSI controller is present, ESX adds several pciBridge devices to vmx file. This fixes an error message where it refuses to create VM due to not enough PCI devices available. This applies only to virtualHW version >= 7. --- src/vmx/vmx.c | 23 +++++++++++++++++++ .../xml2vmx-fusion-in-the-wild-1.vmx | 13 +++++++++++ .../xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx | 13 +++++++++++ .../xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx | 13 +++++++++++ 4 files changed, 62 insertions(+) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 68a199f354..f2ce4bf463 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3082,6 +3082,7 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe int scsi_virtualDev[4] = { -1, -1, -1, -1 }; bool floppy_present[2] = { false, false }; unsigned int maxvcpus; + bool hasSCSI = false; if (ctx->formatFileName == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3288,6 +3289,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe for (i = 0; i < 4; ++i) { if (scsi_present[i]) { + hasSCSI = true; + virBufferAsprintf(&buffer, "scsi%zu.present = \"true\"\n", i); if (scsi_virtualDev[i] != -1) { @@ -3380,6 +3383,26 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe goto cleanup; } + if (virtualHW_version >= 7 && hasSCSI) { + virBufferAddLit(&buffer, "pciBridge0.present = \"true\"\n"); + + virBufferAddLit(&buffer, "pciBridge4.present = \"true\"\n"); + virBufferAddLit(&buffer, "pciBridge4.virtualDev = \"pcieRootPort\"\n"); + virBufferAddLit(&buffer, "pciBridge4.functions = \"8\"\n"); + + virBufferAddLit(&buffer, "pciBridge5.present = \"true\"\n"); + virBufferAddLit(&buffer, "pciBridge5.virtualDev = \"pcieRootPort\"\n"); + virBufferAddLit(&buffer, "pciBridge5.functions = \"8\"\n"); + + virBufferAddLit(&buffer, "pciBridge6.present = \"true\"\n"); + virBufferAddLit(&buffer, "pciBridge6.virtualDev = \"pcieRootPort\"\n"); + virBufferAddLit(&buffer, "pciBridge6.functions = \"8\"\n"); + + virBufferAddLit(&buffer, "pciBridge7.present = \"true\"\n"); + virBufferAddLit(&buffer, "pciBridge7.virtualDev = \"pcieRootPort\"\n"); + virBufferAddLit(&buffer, "pciBridge7.functions = \"8\"\n"); + } + /* Get final VMX output */ if (virBufferCheckError(&buffer) < 0) goto cleanup; diff --git a/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-1.vmx b/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-1.vmx index 56932101c8..ab09bc926d 100644 --- a/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-1.vmx +++ b/tests/xml2vmxdata/xml2vmx-fusion-in-the-wild-1.vmx @@ -28,3 +28,16 @@ ethernet1.addressType = "generated" ethernet1.generatedAddress = "00:0c:29:3b:64:f4" ethernet1.generatedAddressOffset = "0" svga.vramSize = "4194304" +pciBridge0.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" diff --git a/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx index 4211a67e62..acdf7721a9 100644 --- a/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx +++ b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-1.vmx @@ -20,3 +20,16 @@ ethernet0.addressType = "static" ethernet0.address = "00:90:b9:dc:ea:81" ethernet0.checkMACAddress = "false" svga.vramSize = "4194304" +pciBridge0.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" diff --git a/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx index ad68df960b..5086605467 100644 --- a/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx +++ b/tests/xml2vmxdata/xml2vmx-ws-in-the-wild-2.vmx @@ -20,3 +20,16 @@ ethernet0.addressType = "static" ethernet0.address = "00:90:b9:dc:ea:81" ethernet0.checkMACAddress = "false" svga.vramSize = "4194304" +pciBridge0.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" -- GitLab