From nobody Thu Sep 19 01:33:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536121280564393.4698660923723; Tue, 4 Sep 2018 21:21:20 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 808685F726; Wed, 5 Sep 2018 04:21:18 +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 09AB830912F5; Wed, 5 Sep 2018 04:21:18 +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 AAA884BB74; Wed, 5 Sep 2018 04:21:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w854LDJI028616 for ; Wed, 5 Sep 2018 00:21:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 31B66308BDAD; Wed, 5 Sep 2018 04:21:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2817A308BDAB for ; Wed, 5 Sep 2018 04:21:11 +0000 (UTC) Received: from mail-qt0-f193.google.com (mail-qt0-f193.google.com [209.85.216.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D25BC049D5C for ; Wed, 5 Sep 2018 04:21:10 +0000 (UTC) Received: by mail-qt0-f193.google.com with SMTP id h4-v6so6649035qtj.7 for ; Tue, 04 Sep 2018 21:21:10 -0700 (PDT) Received: from localhost.localdomain ([2804:431:b704:f07a:754f:6e69:b49d:d0f3]) by smtp.gmail.com with ESMTPSA id a66-v6sm362192qkf.96.2018.09.04.21.21.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 21:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=81vNFfEvERFeO/spPm9yI9eT7sMFhrQzlFqpT4KJsSs=; b=VBRH72cIqZYb4w5F7Pxnpf5ZX0SfNv7MWOhR+5CXyYcKW1RT2RfEondaN6tE+JIJzD gjHEAXXv5ystc1YyPkVBnVCnW14BaXS80MRUIn4OmaCwo9AtNG+eYXDCdZGRARrfrOaW dAqWKSkw57QrAevli0EOQaWW63WVtL8a1YP+PfJP1/T1opCl/WBSQyWuQBr+fpQ6CWr5 wf20I20+SoCjhu+v/yMKeVHyXwIetXZQf8dgwtFuv3xO/5AnL5Y6imlC/xcWuLLb3c52 6P4lqSDXBHymK6w5/nxKOhJekHFD9DZ7DD7HqMFftXsoaxZ+aTGx4KzZVaO0g+Ij2OGj +tZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=81vNFfEvERFeO/spPm9yI9eT7sMFhrQzlFqpT4KJsSs=; b=lGfy4JFA+uEEndJYf2S05NfzVilEkI5AzzMgaGzrOeKmHg4bl+r3dRqIiWpdsaV8mH mdbvkNEBHAU6HxALdFDKEopOAd7TCqIN83mU1CJjSWLonIJmJgGIt9eFyyF7j+IwMlyc WlkAjJnyKjDl3OjImPCoIMIkFPLDB61LqIr62GcojYKCU6bANYe0w1bGG0qPVrRjVBXZ UbODFsU01VLCm0EN5ZjAw1BB4XT19xusCTYK6b+AnjKRyem2GYRH+O4rYxfSgQdj0/PS uTsdfYeE/WpAgh0b6AIGbVyzaiiAx8SGqnGUQ+5O3suICbkynBDnjt/H3Yb5+flVg1+D NVaA== X-Gm-Message-State: APzg51ASc1whpLmUs+s0DqCMSGtyLsEG4CC3e5CQvvaY/tVMvO0TKkzO 6txt10mPVWg/aFW0PaHaUkHcHqRn X-Google-Smtp-Source: ANB0VdYNwk7EI845oZmfEhGN2vHKq1KKwiSe+d+LXSt8fPQzhQKHn5JIWhEOGFydAQHga197rN5erA== X-Received: by 2002:aed:2e64:: with SMTP id j91-v6mr24337404qtd.318.1536121269058; Tue, 04 Sep 2018 21:21:09 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Wed, 5 Sep 2018 01:20:54 -0300 Message-Id: <20180905042056.21029-3-jcfaracco@gmail.com> In-Reply-To: <20180905042056.21029-1-jcfaracco@gmail.com> References: <20180905042056.21029-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 05 Sep 2018 04:21:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 05 Sep 2018 04:21:10 +0000 (UTC) for IP:'209.85.216.193' DOMAIN:'mail-qt0-f193.google.com' HELO:'mail-qt0-f193.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.108 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.216.193 mail-qt0-f193.google.com 209.85.216.193 mail-qt0-f193.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v5 2/4] qemu: adding domainGetHostname support for QEMU 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 05 Sep 2018 04:21:19 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This commit adds support to use the function qemuAgentGetHostname() for obtain the domain hostname using QEMU-GA command. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/qemu/qemu_driver.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 07ea5473b6..2f8d6915e1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19353,6 +19353,46 @@ qemuConnectGetCPUModelNames(virConnectPtr conn, return virCPUGetModels(arch, models); } =20 + +static char * +qemuDomainGetHostname(virDomainPtr dom, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm =3D NULL; + qemuAgentPtr agent; + char *hostname =3D NULL; + + virCheckFlags(0, NULL); + + if (!(vm =3D qemuDomObjFromDomain(dom))) + return NULL; + + if (virDomainGetHostnameEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_QUERY) < 0) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) + goto endjob; + + if (!qemuDomainAgentAvailable(vm, true)) + goto endjob; + + agent =3D qemuDomainObjEnterAgent(vm); + ignore_value(qemuAgentGetHostname(agent, &hostname)); + qemuDomainObjExitAgent(vm, agent); + + endjob: + qemuDomainObjEndAgentJob(vm); + + cleanup: + virDomainObjEndAPI(&vm); + return hostname; +} + + static int qemuDomainGetTime(virDomainPtr dom, long long *seconds, @@ -19399,6 +19439,7 @@ qemuDomainGetTime(virDomainPtr dom, return ret; } =20 + static int qemuDomainSetTime(virDomainPtr dom, long long seconds, @@ -21957,6 +21998,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .connectGetCPUModelNames =3D qemuConnectGetCPUModelNames, /* 1.1.3 */ .domainFSFreeze =3D qemuDomainFSFreeze, /* 1.2.5 */ .domainFSThaw =3D qemuDomainFSThaw, /* 1.2.5 */ + .domainGetHostname =3D qemuDomainGetHostname, /* 4.8.0 */ .domainGetTime =3D qemuDomainGetTime, /* 1.2.5 */ .domainSetTime =3D qemuDomainSetTime, /* 1.2.5 */ .nodeGetFreePages =3D qemuNodeGetFreePages, /* 1.2.6 */ --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list