From nobody Thu Sep 19 00:53:08 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 1536121303403755.7549842743275; Tue, 4 Sep 2018 21:21:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 742D8C049D65; Wed, 5 Sep 2018 04:21:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37A4760BE5; Wed, 5 Sep 2018 04:21:41 +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 B71B918005DF; Wed, 5 Sep 2018 04:21:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w854LBeq028610 for ; Wed, 5 Sep 2018 00:21:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id C711660922; Wed, 5 Sep 2018 04:21:11 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BEC98608EA for ; Wed, 5 Sep 2018 04:21:09 +0000 (UTC) Received: from mail-qt0-f169.google.com (mail-qt0-f169.google.com [209.85.216.169]) (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 65173308FBA1 for ; Wed, 5 Sep 2018 04:21:08 +0000 (UTC) Received: by mail-qt0-f169.google.com with SMTP id g53-v6so6611781qtg.10 for ; Tue, 04 Sep 2018 21:21:08 -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.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 21:21:06 -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=6va0i7y3IcjpRqmMSwh0SeADXfrHc/pfRGSvUP0/WNs=; b=qzTEYA9dZ3lpqTpizp2k2lAsbyX1kKId2P1Df90tAXy+3xBDGi5b2YIlPZ8qIhNsAo Bs3QFpMbr4xbT5E894Sbtw+KpHAvyuhFaV+P26Sst6od/NuATPf3smRhV46nL0P7/RoC gRrE+stEeYQyuhckbS+PkerhFeMIxCIJ/2FHibfd05VZ30WEmUq0LY8FlgjRZcL4q20X ZN484qjLEa9lHwrGzjmaJbqmUU2U5/lAYJ6BHGLTWxLEkMsyhWijEi37+rUacsDhBlod e/eYa/bbUxke88ePfvs9w9LvPSjV9XY6Got5nl3Op/hro6cNFszfpXM98VPpyUfUgPW6 /2bA== 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=6va0i7y3IcjpRqmMSwh0SeADXfrHc/pfRGSvUP0/WNs=; b=d2BYgxbyUj0lwmpdSDFjdbKjAfqbsDUGW1r8GYahkHSRudiM5eTiuqegbb8CXcnycY CESROZ1PouAMv97K95Muter5JfmyBS+a4un/mJGBrMsbgFg8SdyVmZXgJiupS7hc3Jeh WQFdJr96XV61Cru2nCXkfiE4sVtM6vOD/NOnIBHWJFTVK3bsanfnZycv9+jQaTVerLcV 2tecuGkbOAv8Le2kepZGBV8mxASEk1imymmIt3OFJpRvbtCz4BBSQDkA5OVoYgIW77cL BGDc3AZPAiBSYwAr/yPRORG3PqJkhe9QTWaEi4YVEGwOmhwOc+UmB3gc11GIRyD+N5I4 ftug== X-Gm-Message-State: APzg51BoOsTkukoWo9e/OLvetyAiVqHqP2yF7nvgN2UbLYBt65Bxkdfp XwfCRcQcgJBVrc/peHuouMD0yGkx X-Google-Smtp-Source: ANB0VdYFqXiZsjonQnKP4fxTyvMn1cO4wN13DfVu1pva+20e52HPKKx/d0DIi9Oh6kBilem18kYYag== X-Received: by 2002:ac8:2617:: with SMTP id u23-v6mr33941075qtu.100.1536121267407; Tue, 04 Sep 2018 21:21:07 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Wed, 5 Sep 2018 01:20:53 -0300 Message-Id: <20180905042056.21029-2-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.43]); Wed, 05 Sep 2018 04:21:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 05 Sep 2018 04:21:08 +0000 (UTC) for IP:'209.85.216.169' DOMAIN:'mail-qt0-f169.google.com' HELO:'mail-qt0-f169.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.169 mail-qt0-f169.google.com 209.85.216.169 mail-qt0-f169.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v5 1/4] qemu: implementing qemuAgentGetHostname() function. 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.79 on 10.5.11.12 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:42 +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 implements the function qemuAgentGetHostname() that uses the QEMU guest agent command 'guest-get-host-name' to retrieve the guest hostname of virtual machine running the QEMU-GA. Signed-off-by: Julio Faracco Reviewed-by: John Ferlan --- src/qemu/qemu_agent.c | 47 +++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_agent.h | 4 ++++ 2 files changed, 51 insertions(+) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index bf08871f18..ac728becef 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1683,6 +1683,53 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus, } =20 =20 +int +qemuAgentGetHostname(qemuAgentPtr mon, + char **hostname) +{ + int ret =3D -1; + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + virJSONValuePtr data =3D NULL; + const char *result =3D NULL; + + cmd =3D qemuAgentMakeCommand("guest-get-host-name", + NULL); + + if (!cmd) + return ret; + + if (qemuAgentCommand(mon, cmd, &reply, true, + VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) < 0) + goto cleanup; + + if (qemuAgentCheckError(cmd, reply) < 0) + goto cleanup; + + if (!(data =3D virJSONValueObjectGet(reply, "return"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed return value")); + goto cleanup; + } + + if (!(result =3D virJSONValueObjectGetString(data, "host-name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("'host-name' missing in guest-get-host-name reply= ")); + goto cleanup; + } + + if (VIR_STRDUP(*hostname, result) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} + + int qemuAgentGetTime(qemuAgentPtr mon, long long *seconds, diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 6dd9c702dd..4354b7e0cf 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -105,6 +105,10 @@ int qemuAgentUpdateCPUInfo(unsigned int nvcpus, qemuAgentCPUInfoPtr cpuinfo, int ncpuinfo); =20 +int +qemuAgentGetHostname(qemuAgentPtr mon, + char **hostname); + int qemuAgentGetTime(qemuAgentPtr mon, long long *seconds, unsigned int *nseconds); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list