From nobody Sat May 18 21:26:53 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1714047257586738.0370708957641; Thu, 25 Apr 2024 05:14:17 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6569B2306; Thu, 25 Apr 2024 08:14:16 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7DE11223D; Thu, 25 Apr 2024 08:13:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 268781E61; Thu, 25 Apr 2024 08:13:04 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 58A4A1E67 for ; Thu, 25 Apr 2024 08:13:02 -0400 (EDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-N5mD7ObTN06eIYf1K4d2Hg-1; Thu, 25 Apr 2024 08:13:00 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-34a49f5a6baso758726f8f.3 for ; Thu, 25 Apr 2024 05:13:00 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id k6-20020a5d6286000000b0034c124b80f7sm1340682wru.61.2024.04.25.05.12.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 05:12:58 -0700 (PDT) Received: from wheatley.brq.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id BEB981B3D7641 for ; Thu, 25 Apr 2024 14:12:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: N5mD7ObTN06eIYf1K4d2Hg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714047179; x=1714651979; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MpOdtEHuGtx24RooZ/n3GMCcvkQVOpVdtmmv72qJu7c=; b=RcLbz6fVZ4wBuKvhKFVyCkpaYnSQnczxFqH5BKKWY+sMVbfldM2Py8voljLXVi2o6D uIqCza3AM46vIwJt5sOyq6XpY25OYihACkzFDgHTo8bKQxKgaB4hINnAQjz9lQYXmm87 yABNcJM4HLiSIQhuBGwiXRaWV2qDPe/KAIgfbASbxrWX8C3QN+aZkXwH1VjLJ+sfwJK/ BpH7h0KZ2L3+BE2BcRJzlNebcOmSWcCy2hMrXL0biPYvMIerhcxZTfTliBxGQc0DbvTa BdMS126k9lW9ZMUTcLsuCMdplKI9rtsLKpKCUKsPTtQAEHscmO9YTPIneg0CEhMe5eK1 tnmA== X-Gm-Message-State: AOJu0YxQjEuPB/cRj3MM/Q6Lvh2NhIhibBplcs+rnmvJCU+rDrllVR95 zZ2HkghDIjK9MtDUMi3SzCg2vAhwsl9TWk9zBDbT9Yznqs4X5Ufiq/kH4AKygQqw20Lo+iF8bBs f4VEirk/uSHKFj3YKO7zwGdhoMZCQ81aWWBvDbYEAepghbn+61vNCzqr1cuRT/5qbwQAa2Qo5bR WXIEz2EydFOL8WWWJvzRTuHK+mSLEktDwcjohuxpg= X-Received: by 2002:a5d:550b:0:b0:34b:4d4e:c67a with SMTP id b11-20020a5d550b000000b0034b4d4ec67amr4484635wrv.66.1714047179244; Thu, 25 Apr 2024 05:12:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5Fh0+81NylrWxuKXgAPZNxzQBEIVNH9IzWqZD+BdCSOXSPRtWniSs/W5XrciOU7vAbxplbQ== X-Received: by 2002:a5d:550b:0:b0:34b:4d4e:c67a with SMTP id b11-20020a5d550b000000b0034b4d4ec67amr4484607wrv.66.1714047178641; Thu, 25 Apr 2024 05:12:58 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH] vmx: Check serialX.vspc before serialX.fileName Date: Thu, 25 Apr 2024 14:12:54 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: RPX7N5XBQOVGUY3X76Q25YYUKSQEFW6G X-Message-ID-Hash: RPX7N5XBQOVGUY3X76Q25YYUKSQEFW6G X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1714047259465100001 When using vSPC (Virtual Serial Port Concentrator) in vSphere the actual address for it is saved in serialX.vspc in which case the serialX.fileName is most probably something we can't get any useful information from and we also fail during the parsing rendering any dumpxml and similar tries unsuccessful. Instead of parsing the vspc URL with something along the lines of `virURIParse(vspc ? vspc : fileName)`, which could lead to us reporting information that is very prune to misuse (the vSPC seemingly has a protocol on top of the telnet connection; redefining the domain would change the behaviour; the URL might have a fragment we are not saving; etc.) or adding more XML knobs to indicate vSPC usage (which we would not be able to configure; we'd have to properly error out everywhere; etc.) let's just report dummy serial port that leads to nowhere. Resolves: https://issues.redhat.com/browse/RHEL-32182 Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- src/vmx/vmx.c | 12 +++ tests/vmx2xmldata/esx-in-the-wild-13.vmx | 97 ++++++++++++++++++++++++ tests/vmx2xmldata/esx-in-the-wild-13.xml | 55 ++++++++++++++ tests/vmx2xmltest.c | 1 + 4 files changed, 165 insertions(+) create mode 100644 tests/vmx2xmldata/esx-in-the-wild-13.vmx create mode 100644 tests/vmx2xmldata/esx-in-the-wild-13.xml diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 5da67aae60d9..32074f62e14c 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -2975,6 +2975,9 @@ virVMXParseSerial(virVMXContext *ctx, virConf *conf, = int port, char fileName_name[48] =3D ""; g_autofree char *fileName =3D NULL; =20 + char vspc_name[48] =3D ""; + g_autofree char *vspc =3D NULL; + char network_endPoint_name[48] =3D ""; g_autofree char *network_endPoint =3D NULL; =20 @@ -2997,6 +3000,7 @@ virVMXParseSerial(virVMXContext *ctx, virConf *conf, = int port, VMX_BUILD_NAME(startConnected); VMX_BUILD_NAME(fileType); VMX_BUILD_NAME(fileName); + VMX_BUILD_NAME(vspc); VMX_BUILD_NAME_EXTRA(network_endPoint, "network.endPoint"); =20 /* vmx:present */ @@ -3026,6 +3030,10 @@ virVMXParseSerial(virVMXContext *ctx, virConf *conf,= int port, if (virVMXGetConfigString(conf, fileName_name, &fileName, true) < 0) goto cleanup; =20 + /* vmx:fileName -> def:data.file.path */ + if (virVMXGetConfigString(conf, vspc_name, &vspc, true) < 0) + goto cleanup; + /* vmx:network.endPoint -> def:data.tcp.listen */ if (virVMXGetConfigString(conf, network_endPoint_name, &network_endPoi= nt, true) < 0) { @@ -3057,6 +3065,10 @@ virVMXParseSerial(virVMXContext *ctx, virConf *conf,= int port, (*def)->target.port =3D port; (*def)->source->type =3D VIR_DOMAIN_CHR_TYPE_PIPE; (*def)->source->data.file.path =3D g_steal_pointer(&fileName); + } else if (STRCASEEQ(fileType, "network") && vspc) { + (*def)->target.port =3D port; + (*def)->source->type =3D VIR_DOMAIN_CHR_TYPE_FILE; + (*def)->source->data.file.path =3D g_strdup("/dev/null"); } else if (STRCASEEQ(fileType, "network")) { (*def)->target.port =3D port; (*def)->source->type =3D VIR_DOMAIN_CHR_TYPE_TCP; diff --git a/tests/vmx2xmldata/esx-in-the-wild-13.vmx b/tests/vmx2xmldata/e= sx-in-the-wild-13.vmx new file mode 100644 index 000000000000..1016acab28d8 --- /dev/null +++ b/tests/vmx2xmldata/esx-in-the-wild-13.vmx @@ -0,0 +1,97 @@ +.encoding =3D "UTF-8" +config.version =3D "8" +virtualHW.version =3D "19" +vmci0.present =3D "TRUE" +floppy0.present =3D "FALSE" +memSize =3D "1024" +tools.upgrade.policy =3D "manual" +sched.cpu.units =3D "mhz" +vm.createDate =3D "1704946351823519" +scsi0.virtualDev =3D "lsilogic" +scsi0.present =3D "TRUE" +scsi0:0.deviceType =3D "scsi-hardDisk" +scsi0:0.fileName =3D "Test-Mig-VM-1 (01ce57d0-4e20-41a5-8b6c-bcbf49a032ec)= _2.vmdk" +sched.scsi0:0.shares =3D "normal" +sched.scsi0:0.throughputCap =3D "off" +scsi0:0.present =3D "TRUE" +ethernet0.virtualDev =3D "vmxnet3" +ethernet0.opaqueNetwork.id =3D "25c9a00e-dc60-4918-89b7-41c951988366" +ethernet0.opaqueNetwork.type =3D "nsx.LogicalSwitch" +ethernet0.shares =3D "normal" +ethernet0.addressType =3D "static" +ethernet0.address =3D "fa:16:3e:bb:2c:4a" +ethernet0.externalId =3D "4b57523e-35af-4f8d-b050-1a7410e1a307" +ethernet0.uptCompatibility =3D "TRUE" +ethernet0.present =3D "TRUE" +ethernet0.networkName =3D "Test" +serial0.fileType =3D "network" +serial0.fileName =3D "ZmVybmV0IGdBQUFBQUJrdFotaW8yclpkRXR6N3dBcDdyYkFMaWFU= MVd4RENJSHgtUXpkTlMyTzRRejI3V192QVlOVUY3ZU1SOTNHZXJrN1dGb2stS0EybmpwWFQ4NjJ= NNlgwc2ZDdmNlOE50eFNhcU1XdlNBTmdhazQ1T1J3LUI5OEZsSDdwMDBZa2R6bWt4Y1Ax" +serial0.vspc =3D "telnets://10.28.100.26:18979#thumbprint=3D18:F5:79:E5:73= :A5:22:83:C0:57:B9:B4:FA:CE:60:19:F1:12:F5:7B" +serial0.yieldOnMsrRead =3D "TRUE" +serial0.present =3D "TRUE" +displayName =3D "Test-Mig-VM-1 (01ce57d0-4e20-41a5-8b6c-bcbf49a032ec)" +annotation =3D "name:Test-Mig-VM-1|0Auserid:962314ba515c48388a0e95c0961709= ff|0Ausername:admin|0Aprojectid:b06b5f77b6bb442f85b1c67cff980ef9|0Aprojectn= ame:MIS|0Aflavor:name:mig-test-flavor|0Aflavor:memory_mb:1024|0Aflavor:vcpu= s:1|0Aflavor:ephemeral_gb:0|0Aflavor:root_gb:10|0Aflavor:swap:0|0Aimageid:8= b90d6fa-20ab-4adf-8015-aad3dddb246c|0Apackage:20.6.2|0A" +guestOS =3D "other-64" +toolScripts.afterPowerOn =3D "TRUE" +toolScripts.afterResume =3D "TRUE" +toolScripts.beforeSuspend =3D "TRUE" +toolScripts.beforePowerOff =3D "TRUE" +tools.syncTime =3D "FALSE" +uuid.bios =3D "42 1e b4 58 54 48 fc 12-20 74 83 d5 e4 19 e1 38" +vc.uuid =3D "01 ce 57 d0 4e 20 41 a5-8b 6c bc bf 49 a0 32 ec" +sched.cpu.latencySensitivity =3D "normal" +tools.guest.desktop.autolock =3D "FALSE" +nvram =3D "Test-Mig-VM-1 (01ce57d0-4e20-41a5-8b6c-bcbf49a032ec).nvram" +svga.present =3D "TRUE" +pciBridge0.present =3D "TRUE" +pciBridge4.present =3D "TRUE" +pciBridge4.virtualDev =3D "pcieRootPort" +pciBridge4.functions =3D "8" +pciBridge5.present =3D "TRUE" +pciBridge5.virtualDev =3D "pcieRootPort" +pciBridge5.functions =3D "8" +pciBridge6.present =3D "TRUE" +pciBridge6.virtualDev =3D "pcieRootPort" +pciBridge6.functions =3D "8" +pciBridge7.present =3D "TRUE" +pciBridge7.virtualDev =3D "pcieRootPort" +pciBridge7.functions =3D "8" +hpet0.present =3D "TRUE" +vio.imageId =3D "8b90d6fa-20ab-4adf-8015-aad3dddb246c" +nvp.vm-uuid =3D "01ce57d0-4e20-41a5-8b6c-bcbf49a032ec" +nvp.iface-id.0 =3D "4b57523e-35af-4f8d-b050-1a7410e1a307" +smbios.assetTag =3D "OpenTelekomCloud" +root-disk-uuid =3D "6000C294-db10-e2c6-963f-e4371d3605e8" +numa.autosize.cookie =3D "10012" +numa.autosize.vcpu.maxPerVirtualNode =3D "1" +pciBridge0.pciSlotNumber =3D "17" +pciBridge4.pciSlotNumber =3D "21" +pciBridge5.pciSlotNumber =3D "22" +pciBridge6.pciSlotNumber =3D "23" +pciBridge7.pciSlotNumber =3D "24" +scsi0.pciSlotNumber =3D "16" +ethernet0.pciSlotNumber =3D "160" +vmotion.checkpointFBSize =3D "4194304" +vmotion.checkpointSVGAPrimarySize =3D "4194304" +vmotion.svga.mobMaxSize =3D "4194304" +vmotion.svga.graphicsMemoryKB =3D "4096" +monitor.phys_bits_used =3D "45" +softPowerOff =3D "FALSE" +ctkEnabled =3D "TRUE" +scsi0:0.ctkEnabled =3D "TRUE" +svga.guestBackedPrimaryAware =3D "TRUE" +viv.moid =3D "bd916f5e-a90b-46db-98e8-ce974fef34f4:vm-29145:1NineJhqocLZEZ= 6JOxn/hLdjlihTelLVQGc8mmAj3nA=3D" +migrate.hostLog =3D "Test-Mig-VM-1 (01ce57d0-4e20-41a5-8b6c-bcbf49a032ec)-= 7cedc035.hlog" +sched.cpu.min =3D "0" +sched.cpu.shares =3D "normal" +sched.mem.min =3D "0" +sched.mem.minSize =3D "0" +sched.mem.shares =3D "normal" +migrate.encryptionMode =3D "opportunistic" +ftcpt.ftEncryptionMode =3D "ftEncryptionOpportunistic" +sched.swap.derivedName =3D "/vmfs/volumes/642eff9a-0df93507-cca5-5c6f69c57= c70/Test-Mig-VM-1 (01ce57d0-4e20-41a5-8b6c-bcbf49a032ec)/Test-Mig-VM-1 (01c= e57d0-4e20-41a5-8b6c-bcbf49a032ec)-69fcc9f7.vswp" +uuid.location =3D "56 4d c2 6b 03 eb b2 44-eb 36 8a 83 de 3f bd b6" +scsi0:0.redo =3D "" +vmci0.id =3D "-468065992" +cleanShutdown =3D "TRUE" +vmxstats.filename =3D "Test-Mig-VM-1 (01ce57d0-4e20-41a5-8b6c-bcbf49a032ec= ).scoreboard" diff --git a/tests/vmx2xmldata/esx-in-the-wild-13.xml b/tests/vmx2xmldata/e= sx-in-the-wild-13.xml new file mode 100644 index 000000000000..689282747779 --- /dev/null +++ b/tests/vmx2xmldata/esx-in-the-wild-13.xml @@ -0,0 +1,55 @@ + + Test-Mig-VM-1 (01ce57d0-4e20-41a5-8b6c-bcbf49a032ec) + 421eb458-5448-fc12-2074-83d5e419e138 + name:Test-Mig-VM-1 +userid:962314ba515c48388a0e95c0961709ff +username:admin +projectid:b06b5f77b6bb442f85b1c67cff980ef9 +projectname:MIS +flavor:name:mig-test-flavor +flavor:memory_mb:1024 +flavor:vcpus:1 +flavor:ephemeral_gb:0 +flavor:root_gb:10 +flavor:swap:0 +imageid:8b90d6fa-20ab-4adf-8015-aad3dddb246c +package:20.6.2 + + 1048576 + 1048576 + 1 + + 1000 + + + hvm + + + destroy + restart + destroy + + + + +
+ + + + + + + + + + + + + + + + + + diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 785eee6d3002..0fb5f13f72ce 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -263,6 +263,7 @@ mymain(void) DO_TEST("esx-in-the-wild-10"); DO_TEST("esx-in-the-wild-11"); DO_TEST("esx-in-the-wild-12"); + DO_TEST("esx-in-the-wild-13"); =20 DO_TEST("gsx-in-the-wild-1"); DO_TEST("gsx-in-the-wild-2"); --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org