From nobody Sat May 4 14:36:09 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 1534559147343422.62998308882607; Fri, 17 Aug 2018 19:25:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 442C23084216; Sat, 18 Aug 2018 02:25:43 +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 566DF7BB6D; Sat, 18 Aug 2018 02:25:42 +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 6C0BC4A464; Sat, 18 Aug 2018 02:25:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7I2PctN001955 for ; Fri, 17 Aug 2018 22:25:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7526387B27; Sat, 18 Aug 2018 02:25:38 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6ED3BAE4EF for ; Sat, 18 Aug 2018 02:25:34 +0000 (UTC) Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) (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 F353A3082A2C for ; Sat, 18 Aug 2018 02:25:33 +0000 (UTC) Received: by mail-qk0-f196.google.com with SMTP id b5-v6so7536134qkg.6 for ; Fri, 17 Aug 2018 19:25:33 -0700 (PDT) Received: from localhost.localdomain ([177.103.35.8]) by smtp.gmail.com with ESMTPSA id o124-v6sm2114975qkd.61.2018.08.17.19.25.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Aug 2018 19:25:32 -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=6gC4+NGiWUv5r1wE+0LS2bb/9dqAX/jMsHW3jBPrPMQ=; b=TyOv6KBQNAFVEvAFDGmsJqJpuXhPLNfgWXjOR8E72aB2QXzmKkqo42ZxaAI/9AIMJs I880H/7reJHtUCjnZVMJ5mwCXUpUpZj4R6hlj9ykkO84Cgz1G8SU42fpxE4Ggoh6FIeN 9Nw2ZrSWCjGFpuaEloRR0hWySrirRtiCp5hy8l/Yzo42/5wdnKrSslt0qhYrmUVK0bq6 yF2ZQUErS/LMiOnhpnWC2SCY6RMfIdNoHsJZXm3CuMmrHoeMagtTCEwORfqSM8QJ3qbz gNE6jTIRyXmtV52G8wn0aXB5+/avU0eSciUvsSbmHHpuqbDU7i7oAtm2/BW6C6FIKTml /fWw== 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=6gC4+NGiWUv5r1wE+0LS2bb/9dqAX/jMsHW3jBPrPMQ=; b=de1Jvyzbtza9albq4jtcqlFcfufwqFsxIyQw59ONX8nwNBj+RGXrFCJwIUr+UclXUk vi+ufXfuQHrtIPpF7zWdBDekJmHL4zEvP9FbIOtSgfjWMb96TZ61loXb0ek6FmPH5HEK j6DPQN53fZKrQPBw0qYKO4uxuKtOX/XeaR/x5/UjnccdAoHMUWAVTC+wKlyLZFUuw+ZR 5K6AkQcXTuR1AX9KfvDO2Fe+btcgvF7qCOfu5M0DUr1i+mVZTf0sFl88RalEz5J6wpig VbWvN2ixsfOhSZ9mR54f9OD2ttu1e8aCsTRd/RKkHRUT2oUwIOm+mv84myqjKxj3N1KF heRQ== X-Gm-Message-State: AOUpUlGN6mgZSj/7gtBfAxt5j/8BUL7XmnUrHtpBK5ztoBANK6A/qs1X kaSKbSwLq+YSoTby0rQwm66vOuJZ X-Google-Smtp-Source: AA+uWPxUtDT+FDa+B3WbLXTR0lmiGnQv7Ynca6wogYfi6wTot74oPPTbKEZvXG4vQl7fG0uG/S9CqA== X-Received: by 2002:a37:2a85:: with SMTP id q5-v6mr7496146qkq.390.1534559132994; Fri, 17 Aug 2018 19:25:32 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Fri, 17 Aug 2018 23:25:18 -0300 Message-Id: <20180818022519.23446-2-jcfaracco@gmail.com> In-Reply-To: <20180818022519.23446-1-jcfaracco@gmail.com> References: <20180818022519.23446-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 18 Aug 2018 02:25:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sat, 18 Aug 2018 02:25:34 +0000 (UTC) for IP:'209.85.220.196' DOMAIN:'mail-qk0-f196.google.com' HELO:'mail-qk0-f196.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (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.220.196 mail-qk0-f196.google.com 209.85.220.196 mail-qk0-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sat, 18 Aug 2018 02:25:44 +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 command 'guest-get-host-name' to retrieve the guest hostname of Virtual Machine. It is a possibility where QEMU-GA is running. Signed-off-by: Julio Faracco --- src/qemu/qemu_agent.c | 39 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_agent.h | 4 ++++ 2 files changed, 43 insertions(+) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index bf08871f18..2c7f98378e 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1682,6 +1682,45 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus, return 0; } =20 +int +qemuAgentGetHostname(qemuAgentPtr mon, + char **hostname) +{ + int ret =3D -1; + virJSONValuePtr cmd; + virJSONValuePtr reply =3D NULL; + virJSONValuePtr data =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 (!(data =3D virJSONValueObjectGet(reply, "return"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed return value")); + goto cleanup; + } + + if (VIR_STRDUP(*hostname, + virJSONValueObjectGetString(data, "host-name")) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("'host-name' missing in reply of guest-get-host-n= ame")); + goto cleanup; + } + + ret =3D 0; + + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} =20 int qemuAgentGetTime(qemuAgentPtr mon, 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 From nobody Sat May 4 14:36:09 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 1534559171750733.9670820557077; Fri, 17 Aug 2018 19:26:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B2D503082E05; Sat, 18 Aug 2018 02:26:09 +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 7D2BAAE4EF; Sat, 18 Aug 2018 02:26:09 +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 25B21180610F; Sat, 18 Aug 2018 02:26:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7I2Pdp0001964 for ; Fri, 17 Aug 2018 22:25:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C22E5FCC1; Sat, 18 Aug 2018 02:25:39 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72B1A5FCB7 for ; Sat, 18 Aug 2018 02:25:37 +0000 (UTC) Received: from mail-qt0-f195.google.com (mail-qt0-f195.google.com [209.85.216.195]) (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 2F4CB87621 for ; Sat, 18 Aug 2018 02:25:36 +0000 (UTC) Received: by mail-qt0-f195.google.com with SMTP id m13-v6so10829977qth.1 for ; Fri, 17 Aug 2018 19:25:36 -0700 (PDT) Received: from localhost.localdomain ([177.103.35.8]) by smtp.gmail.com with ESMTPSA id o124-v6sm2114975qkd.61.2018.08.17.19.25.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Aug 2018 19:25:34 -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=4nsLdfi7TysDckd5KQcBKZSUeC+yYY5XGSeQ/xgZNf4=; b=BoTffegXwfJxOFdH8HtFRXBzT26cm8UTRx9dmV1kD5FinYq4dXIHt2Sch6U9+ubAUL geD8SnXPlXw8vW1I+SekkE6+R16f2vQJ+RGWd5Kep9cbGlwms1QQWZ8HvQNghOiQ/p9P S4053ceeCJSqZzrZn7SALtlhbQYXsKVVWcELu7KL1BF4sEXn6gb/RUgYWt7qjGlRApjx wIyd3GHPjhf6teMm+4V3p+r82Z5H700Xa5z2Aoe/WmSJsaSfr0XyXVSd44LTl9DLxGUI g5Xuawse2ZtBH7bN4Fi8VodgljXq438/Av2GdeFp5ZVDY5S4di48P7+OkHFeHjUmL+FN j2TA== 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=4nsLdfi7TysDckd5KQcBKZSUeC+yYY5XGSeQ/xgZNf4=; b=pztpOzf7wJNqWekqxMuOECPbhGPdxMf4AIVJ+S45IDdgR5DfyBBdjHcVwmJEinFhT1 PfS+g41IZgukOt2ct0rz3pRpIi7gQ+sA6nfaGT71Mejk4dKA4RiMKv+dfBFbPrQzaZOV id7lNoIr/7r1sIfMsX+2p21Qu2fAjTLRypaPZaHgGZMlfCSnrgW6Usjn5k0YzEEL0b8U tTu/dyyu5jYug7QLkWPQVkHZjm25vQhEISJhOPb5gw/6E1kM251JEaKtHx9qR/lHTGv3 fjj/CWEvgffglSieKTRDfAuf0QSoUAA1nBj8cs4X4+QArUSq9gB06Jp9u6P93o1uV0wO 0e6A== X-Gm-Message-State: APzg51Bl85dn2yAnrdylAucmqvITLH3/xyTmAjnkTeCqieqfiPhfgx8k SoY8baNkPtlJU1EvB8Sml5tHG+Sg X-Google-Smtp-Source: ANB0VdboWgFZENqxwGLP2OenaR0DPE/XA7XrfeOo/1rpiIampqPFHga3bG5Hg9wdUz9/FqXXDtaWuw== X-Received: by 2002:ac8:4a8c:: with SMTP id l12-v6mr1869131qtq.82.1534559135149; Fri, 17 Aug 2018 19:25:35 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Fri, 17 Aug 2018 23:25:19 -0300 Message-Id: <20180818022519.23446-3-jcfaracco@gmail.com> In-Reply-To: <20180818022519.23446-1-jcfaracco@gmail.com> References: <20180818022519.23446-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sat, 18 Aug 2018 02:25:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sat, 18 Aug 2018 02:25:36 +0000 (UTC) for IP:'209.85.216.195' DOMAIN:'mail-qt0-f195.google.com' HELO:'mail-qt0-f195.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (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.195 mail-qt0-f195.google.com 209.85.216.195 mail-qt0-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 18 Aug 2018 02:26:10 +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 add the support to use the function qemuAgentGetHostname() for obtain the domain hostname using QEMU-GA command. Signed-off-by: Julio Faracco --- src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d4a2379e48..9a6614fbc2 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19309,6 +19309,46 @@ qemuConnectGetCPUModelNames(virConnectPtr conn, return virCPUGetModels(arch, models); } =20 +static char * +qemuDomainGetHostname(virDomainPtr dom, + unsigned int flags) +{ + int rv =3D -1; + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm =3D NULL; + qemuAgentPtr agent; + char *hostname =3D NULL; + + virCheckFlags(0, hostname); + + if (!(vm =3D qemuDomObjFromDomain(dom))) + return NULL; + + if (virDomainGetTimeEnsureACL(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); + rv =3D qemuAgentGetHostname(agent, &hostname); + qemuDomainObjExitAgent(vm, agent); + + endjob: + qemuDomainObjEndAgentJob(vm); + + cleanup: + virDomainObjEndAPI(&vm); + return hostname; +} + + static int qemuDomainGetTime(virDomainPtr dom, long long *seconds, @@ -21787,6 +21827,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.6.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