From nobody Tue May 7 06:53:26 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 1534818918481313.3960474339093; Mon, 20 Aug 2018 19:35:18 -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 39C0F308FB87; Tue, 21 Aug 2018 02:35:16 +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 686CD5C72D; Tue, 21 Aug 2018 02:35:15 +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 0F4164A463; Tue, 21 Aug 2018 02:35:15 +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 w7L2ZBTs032430 for ; Mon, 20 Aug 2018 22:35:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FFCF308BDA2; Tue, 21 Aug 2018 02:35:11 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9505E308BDA0 for ; Tue, 21 Aug 2018 02:35:06 +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 571E43086247 for ; Tue, 21 Aug 2018 02:35:05 +0000 (UTC) Received: by mail-qt0-f193.google.com with SMTP id z8-v6so18590406qto.9 for ; Mon, 20 Aug 2018 19:35:05 -0700 (PDT) Received: from localhost.localdomain ([186.223.39.44]) by smtp.gmail.com with ESMTPSA id s185-v6sm6041917qkd.79.2018.08.20.19.35.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:35:03 -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=QJmEuirrNNHrMFgzrfqLGTAroEROoL3v8yVzWOTNMTc=; b=vW/UnsnaL+bmhFxC2tbdI/5GyA2fkjlf9HGHhVvLrlkjCa5dp4JkH1vjT1uJflBzql T8VzCUNF9TMm41xJDXhiYD0XcS5jwnKpPddGkh2ela/uz9HOQgGn1ZbWArswToDH+TZA nr0aEyqCFq98BAbm6KXlQBR8rD+YvgfcOrQG4n3U6v3gBBS+qk15j+dmZNUcYIQYEfcw DlQQlOOjKeeltUF62Uuk356E49edVC/pYOpD2kQyYu/8tZKNdRBXRI1oRlI3oBCh+sI0 To9tpTLecCogMVvHUuKgRra97acf3hz7KHxC7SG/URwxoR6D85yN1X320vS8q2QOAlPG /w3w== 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=QJmEuirrNNHrMFgzrfqLGTAroEROoL3v8yVzWOTNMTc=; b=ChH/UU75jXP9W3lCRNOvFbquJ6UoGBO781lluywYUhCyFTtSM4mxWH08eB2GySkDbg lzFNCc9JO1wq48NI/9uh4avbG6tm+4vTuSkrICLGNwKuaAN1rrAlxQFRroW9SeRIv7CL gRaQL5y56pGCKSL4AP2vwMaDYuECbDWoicUpuw/qmhQMo3dV636Nlr7QNEQNqpADV3dl qEvR7kjBw5IeRV0FeP7H6a+apjZm9ITJJvh+qslnT0qRuUsMycfNX0ot4lU41eoi2Zaz OBMfsd/flkgd9uLiL3ohs7+ez1wuh0HY6IOa1Q2CKSBile2NzCnQ08Mrnt+/OvsP1WSG Z/gQ== X-Gm-Message-State: AOUpUlFxp4+EVdPql5zUJnzM/PdeA6xBNYwErueKDn9PzhegbrSaxwEO 5uE2ZzqoKWlRdyIyWmhWvzO/lTBD X-Google-Smtp-Source: AA+uWPyc4V+kQeLnlOLLML24KYfNxbqn5XP47CpTfF4X6GLA8KHVdOIpND+3iJvvuVAwmSp/baVaxA== X-Received: by 2002:ac8:242b:: with SMTP id c40-v6mr47155515qtc.209.1534818904355; Mon, 20 Aug 2018 19:35:04 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 20 Aug 2018 23:34:48 -0300 Message-Id: <20180821023449.32269-2-jcfaracco@gmail.com> In-Reply-To: <20180821023449.32269-1-jcfaracco@gmail.com> References: <20180821023449.32269-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 21 Aug 2018 02:35:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 21 Aug 2018 02:35:05 +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.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.193 mail-qt0-f193.google.com 209.85.216.193 mail-qt0-f193.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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.43]); Tue, 21 Aug 2018 02:35:16 +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 | 42 ++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_agent.h | 4 ++++ 2 files changed, 46 insertions(+) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index bf08871f18..2d006b8070 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1682,6 +1682,48 @@ 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 (qemuAgentCheckError(cmd, reply) < 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 Tue May 7 06:53:26 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 1534818915221744.1482114734818; Mon, 20 Aug 2018 19:35:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A04CF3DD47; Tue, 21 Aug 2018 02:35:12 +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 59BEF101F97C; Tue, 21 Aug 2018 02:35:12 +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 DBE614BB75; Tue, 21 Aug 2018 02:35:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7L2ZB1l032425 for ; Mon, 20 Aug 2018 22:35:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4C6502BE58; Tue, 21 Aug 2018 02:35:11 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E3BC2B4BE for ; Tue, 21 Aug 2018 02:35:07 +0000 (UTC) Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) (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 CA17230832D2 for ; Tue, 21 Aug 2018 02:35:06 +0000 (UTC) Received: by mail-qk0-f194.google.com with SMTP id p71-v6so7109191qka.9 for ; Mon, 20 Aug 2018 19:35:06 -0700 (PDT) Received: from localhost.localdomain ([186.223.39.44]) by smtp.gmail.com with ESMTPSA id s185-v6sm6041917qkd.79.2018.08.20.19.35.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Aug 2018 19:35:05 -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=w5LveA6hNtHbpBLuZR0UVwXsUpLG2hbm9BM6Txf2+HI=; b=MgYjDyDglW2YO+KZIAr6HPSURLoqAC0W9HGAIPcPi+KJByTvQVHDBGiMhZxzleZzR5 ybqr5Pli9J/CIkFg7+/aEe8m78OVH1gzwnTdOHDqXbu0oC+AfWOSGKmIKvKZ6C1KjGmo JmGmfijGoYPgCS+fcTwNMar75s+9LbWqzhHveLgUTjVpuitG6AdIXyzIakvo4sF1yWqi aj25CHSovlNZZP1vlFxkXrrd5tRppzTuSP1SvFiO3567n7ANNLbXeQf3htxtUt/FGmfP bQ4nviJC6i2HjCsvl7Ewwh1ofBoRNILfWFgUb16RkVHXVQVGogn8phim7v7iw2o7+gZS CUyw== 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=w5LveA6hNtHbpBLuZR0UVwXsUpLG2hbm9BM6Txf2+HI=; b=eVbhDp6VqZ1d9aQD4+D/4NltVBh17kku96LABvbZbv4ojh3HZhcolvmzKkwR62fABx 1Z6xgAVHumrLe/PqNy7L4E8/ukKPu/FqNWSV3pmhUYC8QPRnIP2r8uaoO5asWjZhFrct 4sWCcnJbNWoJijtCgmPJcK2ehPdlAPT9XjJi43NkljlExiqBBxtlXxLhvDKU99AC+RBc FqGhyvoszsRVI0cmTha99yE6XYFJhcb5Dlz1a5v4mWzs+0hxZYgR2MZLtwfApgKT14BN IK0Ng349DMIIBAnMz8R/FTWrfC/syUFaUAxNyArnSPit2iFYMEwKKgjRCwe3ZxeTxvUI m//Q== X-Gm-Message-State: AOUpUlG8y4CFmUG2tV79xa/OV61N47H3hxKPGnEjjMQXkeub91j4Hym8 otnUV7IAYlJhu+l8/3eQGaBYxJJ/ X-Google-Smtp-Source: AA+uWPzNVADhzrLvzhACIC7yVwjSemMIFTl6rIDM4simrAdfjDqQrTfR8Pm00ZWMfI8sCWURxZC1qA== X-Received: by 2002:a37:4150:: with SMTP id o77-v6mr43725578qka.78.1534818905827; Mon, 20 Aug 2018 19:35:05 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Mon, 20 Aug 2018 23:34:49 -0300 Message-Id: <20180821023449.32269-3-jcfaracco@gmail.com> In-Reply-To: <20180821023449.32269-1-jcfaracco@gmail.com> References: <20180821023449.32269-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 21 Aug 2018 02:35:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 21 Aug 2018 02:35:07 +0000 (UTC) for IP:'209.85.220.194' DOMAIN:'mail-qk0-f194.google.com' HELO:'mail-qk0-f194.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.194 mail-qk0-f194.google.com 209.85.220.194 mail-qk0-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 21 Aug 2018 02:35:13 +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 d4a2379e48..7c4d742444 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19309,6 +19309,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, @@ -21787,6 +21826,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