From nobody Sun May 5 19:18:10 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 1534905604223305.8422843315377; Tue, 21 Aug 2018 19:40:04 -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 A013C5D667; Wed, 22 Aug 2018 02:40:01 +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 2FEE55C8B3; Wed, 22 Aug 2018 02:40:01 +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 B68A018005D0; Wed, 22 Aug 2018 02:40:00 +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 w7M2dwKg019314 for ; Tue, 21 Aug 2018 22:39:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE286A1F0E; Wed, 22 Aug 2018 02:39:58 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D626DA1F04 for ; Wed, 22 Aug 2018 02:39:57 +0000 (UTC) Received: from mail-qk0-f176.google.com (mail-qk0-f176.google.com [209.85.220.176]) (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 B5CA1307D844 for ; Wed, 22 Aug 2018 02:39:55 +0000 (UTC) Received: by mail-qk0-f176.google.com with SMTP id c126-v6so319826qkd.7 for ; Tue, 21 Aug 2018 19:39:55 -0700 (PDT) Received: from localhost.localdomain ([177.83.107.196]) by smtp.gmail.com with ESMTPSA id x206-v6sm229382qka.89.2018.08.21.19.39.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 19:39:54 -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=Seah2OB/Z2OxvfUQU9zu391gF0QVDPcZbb8fpI9ZfZU=; b=WoEg8xbTN6d45/oQjLotS04f5RkL+ksKITZNai6v+n51tGnuywDdoyrl3/Ekqvga+S TAguxolJHsYFZYni55nufPz55sgNHTc/LPgNLzJhioPIyvb78FwXVFth7uHFTSdohrvU BkUhLTh2s6N0u3uRZJloGuG/sD5BTHSoy44rZ79bTSfpBvbAbhhkKqCluN1HTZ3gcKKM Sacu37GGnihkhnGVI7y9Dne+eqzIp622FhBpVojoLEgyDGwxvSvDxI8I/P/GMV7dtJ5k w4Cz1xMEHcnGIN3i+IxGyZ36DWNhHVXDEGEdTBSLSkudfauCh0MObFy/8/Cc7mKYvD8U u9uQ== 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=Seah2OB/Z2OxvfUQU9zu391gF0QVDPcZbb8fpI9ZfZU=; b=h/KDKImCKIuBs6aM9HNRi9aEReBXaCBsAykdhWr7BlPru+Zrf/YkfMbLGCAR5UjuJv 525QvXbJtkedxjKdjOO7vot/YIe8S8Gk+kixE56jSgcn0nDyIjl/Oh7HbsS3XpXhd3FA U3NSrXFHImjblwauCBWNbMc6UMxgWkK5koZ3lCqObqe82HcxV9CCKsLC6FAP07dXAZJo ln0w/X8VSk7uYuAWT4oWcFeqzdhHA1m1Mi9k8o06rx8wPecejDuQPXu/Q178Yb840Va5 z0N3707/EhTacT+dpyMfieyU9co/gqZ2yEHLiLPLlcTXqZhzjsgT9mTdZd57tvxJp+75 nd2A== X-Gm-Message-State: AOUpUlFhouXgtL1C7X+bdzvQbNe7aWZzXACzGz5f2ExpiJdyW9QgkSxv +LjikIGBv5dV4f9aNp+IvXqjut0j X-Google-Smtp-Source: AA+uWPx2M8fNhf7MGP0uLLL0lM1ZXofYDBHteXDoGsSMDYq2umHnjfgdypZOi+zQlEhIjwE8wsF6Zw== X-Received: by 2002:a37:1b91:: with SMTP id m17-v6mr14395804qkh.173.1534905594612; Tue, 21 Aug 2018 19:39:54 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Tue, 21 Aug 2018 23:39:41 -0300 Message-Id: <20180822023942.1370-2-jcfaracco@gmail.com> In-Reply-To: <20180822023942.1370-1-jcfaracco@gmail.com> References: <20180822023942.1370-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 22 Aug 2018 02:39:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 22 Aug 2018 02:39:55 +0000 (UTC) for IP:'209.85.220.176' DOMAIN:'mail-qk0-f176.google.com' HELO:'mail-qk0-f176.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.111 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.220.176 mail-qk0-f176.google.com 209.85.220.176 mail-qk0-f176.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 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.39]); Wed, 22 Aug 2018 02:40:02 +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 Reviewed-by: John Ferlan --- 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..7aba4ed366 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")) <=3D 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 Sun May 5 19:18:10 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 1534905612115729.9786413297968; Tue, 21 Aug 2018 19:40:12 -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 96E47C05AA51; Wed, 22 Aug 2018 02:40:09 +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 577E8A1F04; Wed, 22 Aug 2018 02:40: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 01A584A463; Wed, 22 Aug 2018 02:40:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7M2e0WZ019326 for ; Tue, 21 Aug 2018 22:40:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1D614CC; Wed, 22 Aug 2018 02:40:00 +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 98F3E5C8B3 for ; Wed, 22 Aug 2018 02:39:58 +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 1EEE5308FB87 for ; Wed, 22 Aug 2018 02:39:57 +0000 (UTC) Received: by mail-qt0-f195.google.com with SMTP id n6-v6so567886qtl.4 for ; Tue, 21 Aug 2018 19:39:57 -0700 (PDT) Received: from localhost.localdomain ([177.83.107.196]) by smtp.gmail.com with ESMTPSA id x206-v6sm229382qka.89.2018.08.21.19.39.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 19:39:55 -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=ZPGnBZPU/s1ZOPH8eg+BLv4N42XfsqYiT9phfirBZnk=; b=jT646MzJkK2EHshN/Pn6xHTfsoNt1Cws7SDu0lFMyCKu91lMBk3qik2ccvST6AKvu5 v98cWNuq4mfnX3Oz6cEPny/QylPF5PW+rQ7ID/KYzm2381TYal5+xM2oZCXsXhldvuPI fRaA/hvpPkoS/eXEUvPU6sPYSfDY56w8Ne/lguIcJbgcKyNAbweemsrTVemkmcwx2kVT 8PuY/qY4vHhidpv+PvxBF9X2sp8QdJbWVPon5eiYjrJwjlYrjsmVu8l5FmPIPtWe4DqC u0EYNhCrk9l6XQjBbCxIqY1kxuXwSKkKG2tLCgz46Di8+54SPQYq2tJIRRu9/pFTcYh7 1flA== 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=ZPGnBZPU/s1ZOPH8eg+BLv4N42XfsqYiT9phfirBZnk=; b=uVJ+lJ/SU1p+ERld+SGoDHtM+4487JIyRXcpWFO9n8dyq2+HCZ9crLyGgoHrh0eQx0 KfqvlNbReXf/Ty7kboUTTw4QDcp9jivZTQ2QpeEYKKjqsUexmpc1sTsooHfNmrKdegY0 K5DgViQp3ThBP7HclkqT0qD3Fv2Jkh3bTcEbOBr0mls+q6bpxmWnUuD0SahjpIZas7h5 /QkkXVJdUg3iK3hDlfZu5tryjZn6MXnIs7+KHAUxPCIXuaSJDzrL5cdNVzfmz/g/XxAV T7ad2rADtrKtILi4E9VUmaPRU+iK6VDXZytqJbg5g5gdg+KD5s37q70/LnPVa2Awy+y3 9IVA== X-Gm-Message-State: APzg51AKqEgWstY2GAjrrolcyY9wbsX5Whnj5vj/sDz0vtvmChKFNTz9 VDN8F9pIf+yD3pa1aOYpkAE5L7Om X-Google-Smtp-Source: ANB0VdY14/xGaHRs6C435e2Vv3v1WEiVYs/FmPeHf5iXYaqRz9faVJ7lRN13Y5yF1kP8SaGaETRFbw== X-Received: by 2002:ac8:3784:: with SMTP id d4-v6mr1900969qtc.128.1534905595982; Tue, 21 Aug 2018 19:39:55 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Tue, 21 Aug 2018 23:39:42 -0300 Message-Id: <20180822023942.1370-3-jcfaracco@gmail.com> In-Reply-To: <20180822023942.1370-1-jcfaracco@gmail.com> References: <20180822023942.1370-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, 22 Aug 2018 02:39:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 22 Aug 2018 02:39:57 +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.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 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.32]); Wed, 22 Aug 2018 02:40: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 | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 21e9e87ddd..5f53cbea15 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19351,6 +19351,45 @@ 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, @@ -21955,6 +21994,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.7.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