From nobody Mon Feb 9 00:54:35 2026 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 1536115132312981.2887003212753; Tue, 4 Sep 2018 19:38:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4771930024F1; Wed, 5 Sep 2018 02:38:50 +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 0E5252008259; Wed, 5 Sep 2018 02:38:50 +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 58CDD181A12D; Wed, 5 Sep 2018 02:38:49 +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 w852cmef017934 for ; Tue, 4 Sep 2018 22:38:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 09876608EE; Wed, 5 Sep 2018 02:38:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 000366B8DE for ; Wed, 5 Sep 2018 02:38:46 +0000 (UTC) Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.170]) (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 F1E26308A95D for ; Wed, 5 Sep 2018 02:38:44 +0000 (UTC) Received: by mail-qt0-f170.google.com with SMTP id r37-v6so6481703qtc.0 for ; Tue, 04 Sep 2018 19:38:44 -0700 (PDT) Received: from localhost.localdomain ([2804:431:b704:f07a:754f:6e69:b49d:d0f3]) by smtp.gmail.com with ESMTPSA id v13-v6sm298798qtg.82.2018.09.04.19.38.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 19:38:43 -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=TO1/hn6MDrC7iakkaIef1CU9R7u+Hndw+fWNhF7qMlsxL8LomvGSlVaT+a/P1dRuvO iDNffYlbeCF84oQTdpCMu3USm3G4UsammD4f/yBxM/D1WOokQmnjr21QjjKBnZyB4o8N QPNoc9huf7IHqwFzW+82VEFlIIDsr6vsCgjWhrMDd3U2XUfUdubUfWxwM+evKIJyDeLU 8a6j4GApHZiyq2lCML+PT3JFyHI2kpJTNRg8zdAalJBdUxGr4f5+BEX+Eu74fctCbo0t zyBtkcWqP7IQr+y5SqxxBHnpgaC9/1sI8AVM2pP0MDUI0BHsBNrq+gC/jFxvm9zSr+Kx sefw== 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=OAz+odIxRN4xrPyr/GjFObCQM7k1phn/sKTzs3kyo7PLEklQimVr1bo6jUWCE5PeCM EJ6VRvpfrEjAuyyQCupSQAPdOv3+fgeujyexgCy9YOTh0vTvohIuQwjb/9ZdFVyGjIRa 1h1cSJT35jNs/0Ta2uWI1vw04di27jLddE5EnXJzlDjAnE9DdtoDbX9W9jbZZxo0fPsx zTXpWJkJylN3Y2PbfT/EHvRYLjLSqdLDEWyX1Ns3A4JxF7miONjEMQEXFUKdFlFAGHmi y4HfawILCi1rud+ZN5Y1Ncx6Rm/Lw92PqPzxivs1njKkkX42MH7ZTebvEYpblVCWKni6 INqQ== X-Gm-Message-State: APzg51Dk55eFycj7tZsCr6nExWy2e/Pm0yQpNDqtPdvn7EZR7S0iTSXV 79xxHEfUpy7YHo21AU3vLDaiiOC4 X-Google-Smtp-Source: ANB0Vdagi8BWiakyEadY1bZ3+5xAFTaBoXZkkzco5T9N2bvIExaPMBgHOHKiPWcx6gIGYMz3Yc2gYg== X-Received: by 2002:ac8:7254:: with SMTP id l20-v6mr32608235qtp.108.1536115124010; Tue, 04 Sep 2018 19:38:44 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Tue, 4 Sep 2018 23:38:30 -0300 Message-Id: <20180905023833.4867-2-jcfaracco@gmail.com> In-Reply-To: <20180905023833.4867-1-jcfaracco@gmail.com> References: <20180905023833.4867-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 05 Sep 2018 02:38:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 05 Sep 2018 02:38:45 +0000 (UTC) for IP:'209.85.216.170' DOMAIN:'mail-qt0-f170.google.com' HELO:'mail-qt0-f170.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.216.170 mail-qt0-f170.google.com 209.85.216.170 mail-qt0-f170.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4 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.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 05 Sep 2018 02:38:50 +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 --- 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