From nobody Mon Feb 9 18:17:45 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564666658; cv=none; d=zoho.com; s=zohoarc; b=l7sjglkqZ7kDmY+yppkq4JbuFWNVDX9Z6TgoLmGGDoHu38NhnvUvtWjXLlo4Oi8iESCLP+hnA24KDXFCZ+uVfN6RquyCl8j4SqSkv02MBR1+IX2YGuQmNpPoV/4ZyESk1UC+puJHtkKmKZNGFHFUMDAvuAIYYsGr1otNZAKzTl4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564666658; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=is7PR0ROHhDzOXCp80LZN9zLlH2GCa7V0jyWrT2KDQ8=; b=baX0ac1CCznTGGJ+UvWvV0RJ7DEfPs1+f3vUhzUe3v2ObBZIlkRhNV3SMoEyTByRHXBGqDQ2WBBF5GUDW4BveDL4/U6/59vMV3uD7fajMrzv/Tc71EptAgAYLD3Rwh9Pi62MRpJCZuJ7lBQI3eED3UbjCDHANDMrqDcPRcNByv4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564666658821590.0170922154224; Thu, 1 Aug 2019 06:37:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 379B4C0703C5; Thu, 1 Aug 2019 13:37:37 +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 10D2C5D9D3; Thu, 1 Aug 2019 13:37:37 +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 CBFFB180BA9A; Thu, 1 Aug 2019 13:37:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x71DbHTm016318 for ; Thu, 1 Aug 2019 09:37:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id D79A3600F8; Thu, 1 Aug 2019 13:37:17 +0000 (UTC) Received: from himantopus.redhat.com (ovpn-117-216.phx2.redhat.com [10.3.117.216]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 91FEC600C4; Thu, 1 Aug 2019 13:37:17 +0000 (UTC) From: Jonathon Jongsma To: libvir-list@redhat.com Date: Thu, 1 Aug 2019 08:37:09 -0500 Message-Id: <20190801133710.19096-7-jjongsma@redhat.com> In-Reply-To: <20190801133710.19096-1-jjongsma@redhat.com> References: <20190801133710.19096-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: tgolembi@redhat.com Subject: [libvirt] [PATCH 6/7] qemu: Implement virDomainGetGuestInfo() 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: , 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 01 Aug 2019 13:37:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Iimplements the new guest information API by querying requested information via the guest agent. Signed-off-by: Jonathon Jongsma --- src/qemu/qemu_driver.c | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4ca3eb7bde..042e91cfed 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -23061,6 +23061,82 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr domai= n, return ret; } =20 +static unsigned int supportedGuestInfoTypes =3D + VIR_DOMAIN_GUEST_INFO_USERS | + VIR_DOMAIN_GUEST_INFO_OS | + VIR_DOMAIN_GUEST_INFO_TIMEZONE | + VIR_DOMAIN_GUEST_INFO_HOSTNAME; + +static void +qemuDomainGetGuestInfoCheckSupport(unsigned int *types) +{ + if (*types =3D=3D 0) + *types =3D supportedGuestInfoTypes; + + *types =3D *types & supportedGuestInfoTypes; +} + +static int +qemuDomainGetGuestInfo(virDomainPtr dom, + unsigned int types, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + virQEMUDriverPtr driver =3D dom->conn->privateData; + virDomainObjPtr vm =3D NULL; + qemuAgentPtr agent; + int ret =3D -1; + int rv =3D -1; + int maxparams =3D 0; + char *hostname =3D NULL; + + virCheckFlags(0, ret); + qemuDomainGetGuestInfoCheckSupport(&types); + + if (!(vm =3D qemuDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainGetGuestInfoEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_QUERY) < 0) + goto cleanup; + + if (!qemuDomainAgentAvailable(vm, true)) + goto endjob; + + agent =3D qemuDomainObjEnterAgent(vm); + if ((types & VIR_DOMAIN_GUEST_INFO_USERS) && + qemuAgentGetUsers(agent, params, nparams, &maxparams) < 0) + goto exitagent; + if ((types & VIR_DOMAIN_GUEST_INFO_OS) && + qemuAgentGetOSInfo(agent, params, nparams, &maxparams) < 0) + goto exitagent; + if ((types & VIR_DOMAIN_GUEST_INFO_TIMEZONE) && + qemuAgentGetTimezone(agent, params, nparams, &maxparams) < 0) + goto exitagent; + if ((types & VIR_DOMAIN_GUEST_INFO_HOSTNAME) && + qemuAgentGetHostname(agent, &hostname) < 0) + goto exitagent; + if (virTypedParamsAddString(params, nparams, &maxparams, "hostname", + hostname) < 0) + goto exitagent; + + rv =3D 0; + +exitagent: + qemuDomainObjExitAgent(vm, agent); + + endjob: + qemuDomainObjEndAgentJob(vm); + + cleanup: + virDomainObjEndAPI(&vm); + VIR_FREE(hostname); + return rv; +} + static virHypervisorDriver qemuHypervisorDriver =3D { .name =3D QEMU_DRIVER_NAME, .connectURIProbe =3D qemuConnectURIProbe, @@ -23296,6 +23372,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainCheckpointLookupByName =3D qemuDomainCheckpointLookupByName, /*= 5.6.0 */ .domainCheckpointGetParent =3D qemuDomainCheckpointGetParent, /* 5.6.0= */ .domainCheckpointDelete =3D qemuDomainCheckpointDelete, /* 5.6.0 */ + .domainGetGuestInfo =3D qemuDomainGetGuestInfo, /* 5.6.0 */ }; =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list