From nobody Sun May 5 02:02:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1627547576; cv=none; d=zohomail.com; s=zohoarc; b=c6otRTeSm7IrVRGh1/g9HRsJfLoeQpmuwVCjcs4dKJY6ExB0evs5coSODQOG9637iU4818bOOrVrJFHkrwzwLtN5i8zXMzT1lDa5ykcN2wZfZ5JlOEdD/Usppyx2zPDqm+1I1K/ne5h1/vYC1OOTJkg/QYbGdsmS+hALIbw1TmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627547576; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=tBtMDqCTAoaKvMwBDcx5xFLc9j+lZ5sFsdRIyJ9X498=; b=Gzq+v8y1AysWKuvAKd6vcCw35kQUlJLNmGvcW4YP5GiR8DrOiuTeAyGsWCzXFhgxZW2fTLp+V0eZKyBilqJNcyIxCr8EDfw9/P6obsY+0ZA5ct9Gq2AapffN6lfnko+YmPrdrAVeloaXCCEsrxpPnYlkMHRi0oZ6YJhqcT/Atqg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1627547576480765.5469345013358; Thu, 29 Jul 2021 01:32:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-_n6HUaQwOPCcSQ9upaU_pA-1; Thu, 29 Jul 2021 04:32:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E084B760C4; Thu, 29 Jul 2021 08:32:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9E1406A8F7; Thu, 29 Jul 2021 08:32:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id EC73F4BB7B; Thu, 29 Jul 2021 08:32:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 16T8Ua6T020738 for ; Thu, 29 Jul 2021 04:30:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id B4A5B12C82; Thu, 29 Jul 2021 08:30:36 +0000 (UTC) Received: from bart.redhat.com (unknown [10.43.2.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B4AA5DEFB for ; Thu, 29 Jul 2021 08:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627547575; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tBtMDqCTAoaKvMwBDcx5xFLc9j+lZ5sFsdRIyJ9X498=; b=OTEIEoJM3DCCCnBKOXn8Uh7WUJaA/nIhZ4b0TNccTQbhvfgdYBpFuZ2eF2T1uBZUtp1OUz m7at6PejqUmhQyjhQpq7M8nfUdvuBDPsdruyff+TONVDH3bT9HnK6YTWIWKSBRrJYCetzF YzO5s28yLP5QoA5urTqpfSNVC+A2VN0= X-MC-Unique: _n6HUaQwOPCcSQ9upaU_pA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] vmx: Parse vm.genid Date: Thu, 29 Jul 2021 10:30:30 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1627547577358100001 Content-Type: text/plain; charset="utf-8" The VMware metadata file contains genid but we are not parsing and thus reporting it in domain XML. However, it's not as straightforward as one might think. The UUID reported by VMware is not in its usual string form, but split into two signed long longs. That means, we have to do a bit of trickery when parsing. But looking around it's the same magic that libguestfs does: https://github.com/libguestfs/virt-v2v/blob/master/v2v/input_vmx.ml#L421 It's also explained by Rich on qemu-devel: https://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg02019.html Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1598348 Signed-off-by: Michal Privoznik Reviewed-by: Richard W.M. Jones --- I've successfully ran vmx2xmltest on an s390x machine which means that there shouldn't be any endiandness problem. src/vmx/vmx.c | 30 +++++++++++++++++++ .../vmx2xml-esx-in-the-wild-10.xml | 1 + 2 files changed, 31 insertions(+) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 1cd5a82227..04eabff18a 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1337,6 +1337,32 @@ virVMXConfigScanResultsCollector(const char* name, } =20 =20 +static int +virVMXParseGenID(virConf *conf, + virDomainDef *def) +{ + long long vmid[2] =3D { 0 }; + g_autofree char *uuidstr =3D NULL; + + if (virVMXGetConfigLong(conf, "vm.genid", &vmid[0], 0, true) < 0 || + virVMXGetConfigLong(conf, "vm.genidX", &vmid[1], 0, true) < 0) + return -1; + + if (vmid[0] =3D=3D 0 && vmid[1] =3D=3D 0) + return 0; + + uuidstr =3D g_strdup_printf("%.16llx%.16llx", vmid[0], vmid[1]); + if (virUUIDParse(uuidstr, def->genid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not parse UUID from string '%s'"), uuidstr= ); + return -1; + } + def->genidRequested =3D true; + + return 0; +} + + =20 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * * VMX -> Domain XML @@ -1466,6 +1492,10 @@ virVMXParseConfig(virVMXContext *ctx, } } =20 + /* vmx:vm.genid + vm.genidX -> def:genid */ + if (virVMXParseGenID(conf, def) < 0) + goto cleanup; + /* vmx:annotation -> def:description */ if (virVMXGetConfigString(conf, "annotation", &def->description, true) < 0) { diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml b/tests/vmx2x= mldata/vmx2xml-esx-in-the-wild-10.xml index b8c522af1f..47ed637920 100644 --- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml +++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-10.xml @@ -1,6 +1,7 @@ w2019biosvmware 421a6177-5aa9-abb7-5924-fc376c18a1b4 + 13c67c91-9f47-526f-b0d6-e4dd2e4bb4f9 4194304 4194304 2 --=20 2.31.1