From nobody Tue Sep 22 02:44:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1784379656; cv=none; d=zohomail.com; s=zohoarc; b=E1T5oXqPBXGlSGucs1rhiqyzKQirnJB2AdquD4wUBcaLRGoB1G5QAjdEDE19nN+Rl/8BcVa1JSc6th4GManVRewztwvQ4DKpDnI2QjvoPK0/tjpO7lTHlW/d5vl0c7QEX9ZNbs6SNl3SwFlkXn3t8C6Ba1RCfUaI6PrB+bpX+oU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784379656; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=RymvE6xvEYaIZWYcl1GEWOjubO+8DD8Dd2riiGiW/9E=; b=HrZuFBNi+oxq5xODSWhkcUYxbIckl5yLNZk2j8MFBvIIIXYYdIdpjZqzwL4XXeurkTu0DUpFytA6S6Q/Mv/+jQaLqLaocPMmPaTfz6xOdUURzQwJC72wV5CT/ZB053fBZBp35sXTNVvRJkcpzkz1K84YM41ZLVazZCtD5V5C3fc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 1784379656774655.6960039172941; Sat, 18 Jul 2026 06:00:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9E12B41C13; Sat, 18 Jul 2026 09:00:55 -0400 (EDT) Received: from [172.19.199.10] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id C583341C32; Sat, 18 Jul 2026 08:58:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E599F4196F; Sat, 18 Jul 2026 08:58:31 -0400 (EDT) Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B7FE641ADC for ; Sat, 18 Jul 2026 08:58:30 -0400 (EDT) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-c15e03c2763so554583666b.0 for ; Sat, 18 Jul 2026 05:58:30 -0700 (PDT) Received: from tulp.my.domain (2001-1c02-1a15-3000-ee82-4536-a8f2-9e22.cable.dynamic.v6.ziggo.nl. [2001:1c02:1a15:3000:ee82:4536:a8f2:9e22]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c1740bf48d9sm209276066b.57.2026.07.18.05.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Jul 2026 05:58:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784379509; x=1784984309; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RymvE6xvEYaIZWYcl1GEWOjubO+8DD8Dd2riiGiW/9E=; b=acagT9zNS80XgOD1uRS/+1B8/lfZIXh4mIAnKo3FghwtFAMxipo8wFCzUXoFDCG6L2 FMQRh5mDMHGVB33IpPNqHAKHdhmZv+8v44mVkpRIA4j0pP8p/w+JoFL04JgIWuyKSNS5 96kxCUeYrkjfh8NYFfp0AxXkAi1DqsRzjCEmI+Wz6PJ1Gf4WFQuswySTkFnb7AJ7KVFz Kej/E2y+9Zj3UICII+V+fciUKok33ILMRPXXpHgxH9oYbnx7WuQD8QJlicb8McMIWQEH 6tZdhldpHpGcpCQuZIKYgr7wW+hTnROVXr5tCvpYoeuBDwhhmQNI7HHkQpcfPntCS3fX y3Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784379509; x=1784984309; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RymvE6xvEYaIZWYcl1GEWOjubO+8DD8Dd2riiGiW/9E=; b=E7QE7MKTAhfM3iXia63k7Yzbs4LMctAkNKSl2TM9oxQAa/3Ej4IqsAHsIox/03Rw+P B+vRZMu7X2RGVxMlRUVgxco+knZuMuDK0TqqGW31ebbNuU51iB6n+z6fQoH1uf7FVM1n HGvzkOQvsH8WF7dDZH+nDh4t7CKSuWbF2T0V1MQh3tl0/Awk8ZvhYiMrFOouoGYH6S06 yCCrYn1awNTuZx5LICaggcD/0hWucodrzkkgITGfDqqDj3CK822mFJ2i4oxEP/PmUAwv 9nBQPIxV0IzwtnEgtDL04RP11XiuRCpk/8IcMq+ALcfT0omZjXYBOpQR9iEQCEDydVyV ng2Q== X-Gm-Message-State: AOJu0YxaFKeskCBrSzvHgvshrotkbsm3v3UEglry/XRJCsxhFDtStjaC V3gUKmsI2sYnw2yJLrJP85FyYnnXKJf/I2DmMfSaQe7mrmGo5So76TZf1gSI0If2 X-Gm-Gg: AfdE7ckVCW27uqKrcxOfjnBwZPGtdZN8g4wzRGN60CnlJm3fYgpOzsEmwYcQN+ikDYO Nmx2mLBvoXOtuMeOiZR1/j5ApST6+LB8VdRgK6chlbcvEKbHMyMN/vSsc4dye5i2xXnxW4Kjtdv evd5VlK1DTU6vRik/rqaeQXPubA4CIr14LyUxCsc4DR+qQBPffyyxBPxVMRbF2Jbb5bnbXnFVl6 o/ywAJjNvGfQue3u615Y4x8a9sFyO8hGCi6tE8PjSJbZe3VXotKk4fxZe5U22PFS8JeskKvHziL NAKPnY2djzWm6ujtp013ieTHw4hNAWtyVqSoGonT7ASrffd/6fd+MbS65Ihv0V3AUDY/YOVo1eb QN0ZgQgYfW61cdAK3hG3jZOrMwFNVSqcjrtBPYvfcBo+18hp2Gj0GzMoFuF/QdlnRsS5OHx52nr ptiSYZexyoHxG6shCqnDDR9KjOsw0jsMkFdJFddssNuCGzd7hszchJyQSQKS8tbSVecbvgcdCxd sJI1SaB1kl5/ZPr X-Received: by 2002:a17:907:970c:b0:c12:5970:e62d with SMTP id a640c23a62f3a-c16b416c0a3mr355088666b.29.1784379509313; Sat, 18 Jul 2026 05:58:29 -0700 (PDT) From: Roman Bogorodskiy To: devel@lists.libvirt.org Subject: [PATCH 2/2] bhyve: implement virDomainGetGuestInfo() Date: Sat, 18 Jul 2026 14:57:55 +0200 Message-ID: <20260718125755.6953-3-bogorodskiy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260718125755.6953-1-bogorodskiy@gmail.com> References: <20260718125755.6953-1-bogorodskiy@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UEHHCQ5P35WBSR4EPYCGKGTM4V7YNW36 X-Message-ID-Hash: UEHHCQ5P35WBSR4EPYCGKGTM4V7YNW36 X-MailFrom: bogorodskiy@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Roman Bogorodskiy X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1784379658704158500 Content-Type: text/plain; charset="utf-8" Implementation is pretty similar to the one found in the qemu driver. Signed-off-by: Roman Bogorodskiy Reviewed-by: Peter Krempa --- src/bhyve/bhyve_driver.c | 192 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 192 insertions(+) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index a0d97d3f86..d72b97c7ac 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -2807,6 +2807,197 @@ bhyveDomainRename(virDomainPtr domain, return ret; } =20 +static const unsigned int bhyveDomainGetGuestInfoSupportedTypes =3D + VIR_DOMAIN_GUEST_INFO_USERS | + VIR_DOMAIN_GUEST_INFO_OS | + VIR_DOMAIN_GUEST_INFO_TIMEZONE | + VIR_DOMAIN_GUEST_INFO_HOSTNAME | + VIR_DOMAIN_GUEST_INFO_FILESYSTEM | + VIR_DOMAIN_GUEST_INFO_DISKS | + VIR_DOMAIN_GUEST_INFO_INTERFACES | + VIR_DOMAIN_GUEST_INFO_LOAD; + +static int +bhyveDomainGetGuestInfoCheckSupport(unsigned int types, + unsigned int *supportedTypes) +{ + if (types =3D=3D 0) { + *supportedTypes =3D bhyveDomainGetGuestInfoSupportedTypes; + return 0; + } + + *supportedTypes =3D types & bhyveDomainGetGuestInfoSupportedTypes; + + if (types !=3D *supportedTypes) { + virReportError(VIR_ERR_INVALID_ARG, + _("unsupported guest information types '0x%1$x'"), + types & ~bhyveDomainGetGuestInfoSupportedTypes); + return -1; + } + + return 0; +} + + +static int +bhyveDomainGetGuestInfo(virDomainPtr domain, + unsigned int types, + virTypedParameterPtr *params, + int *nparams, + unsigned int flags) +{ + virDomainObj *vm =3D NULL; + qemuAgent *agent =3D NULL; + int ret =3D -1; + g_autofree char *hostname =3D NULL; + unsigned int supportedTypes; + bool report_unsupported =3D types !=3D 0; + int rc; + size_t nfs =3D 0; + qemuAgentFSInfo **agentfsinfo =3D NULL; + size_t ndisks =3D 0; + qemuAgentDiskInfo **agentdiskinfo =3D NULL; + virDomainInterfacePtr *ifaces =3D NULL; + size_t nifaces =3D 0; + double load1m =3D 0; + double load5m =3D 0; + double load15m =3D 0; + bool format_load =3D false; + size_t i; + g_autoptr(virTypedParamList) list =3D virTypedParamListNew(); + + if (bhyveDomainGetGuestInfoCheckSupport(types, &supportedTypes) < 0) + return -1; + + virCheckFlags(0, -1); + + if (!(vm =3D bhyveDomObjFromDomain(domain))) + goto cleanup; + + if (virDomainGetGuestInfoEnsureACL(domain->conn, vm->def) < 0) + goto cleanup; + + if (virDomainObjBeginAgentJob(vm, VIR_AGENT_JOB_QUERY) < 0) + goto cleanup; + + if (bhyveDomainEnsureAgent(vm, true) < 0) + goto endagentjob; + + agent =3D bhyveDomainObjEnterAgent(vm); + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_USERS && + qemuAgentGetUsers(agent, list, report_unsupported) =3D=3D -1) + goto exitagent; + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_OS && + qemuAgentGetOSInfo(agent, list, report_unsupported) =3D=3D -1) + goto exitagent; + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_TIMEZONE && + qemuAgentGetTimezone(agent, list, report_unsupported) =3D=3D -1) + goto exitagent; + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME && + qemuAgentGetHostname(agent, &hostname, report_unsupported) =3D=3D = -1) + goto exitagent; + + if (hostname) + virTypedParamListAddString(list, hostname, + VIR_DOMAIN_GUEST_INFO_HOSTNAME_HOSTNAME= ); + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) { + rc =3D qemuAgentGetFSInfo(agent, &agentfsinfo, report_unsupported); + if (rc =3D=3D -1) + goto exitagent; + if (rc >=3D 0) + nfs =3D rc; + } + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_DISKS) { + rc =3D qemuAgentGetDisks(agent, &agentdiskinfo, report_unsupported= ); + if (rc =3D=3D -1) + goto exitagent; + if (rc >=3D 0) + ndisks =3D rc; + } + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_INTERFACES) { + rc =3D qemuAgentGetInterfaces(agent, &ifaces, report_unsupported); + if (rc =3D=3D -1) + goto exitagent; + if (rc >=3D 0) + nifaces =3D rc; + } + + if (supportedTypes & VIR_DOMAIN_GUEST_INFO_LOAD) { + rc =3D qemuAgentGetLoadAvg(agent, &load1m, &load5m, &load15m, repo= rt_unsupported); + if (rc =3D=3D -1) + goto exitagent; + if (rc >=3D 0) + format_load =3D true; + } + + bhyveDomainObjExitAgent(vm, agent); + virDomainObjEndAgentJob(vm); + + if (nfs > 0 || ndisks > 0) { + if (virDomainObjBeginJob(vm, VIR_JOB_QUERY) < 0) + goto cleanup; + + if (virDomainObjCheckActive(vm) < 0) + goto endjob; + + /* we need to convert the agent fsinfo struct to parameters and ma= tch + * it to the vm disk target */ + if (nfs > 0) + qemuAgentFSInfoFormatParams(agentfsinfo, nfs, vm->def, list); + + if (ndisks > 0) + qemuAgentDiskInfoFormatParams(agentdiskinfo, ndisks, vm->def, = list); + + endjob: + virDomainObjEndJob(vm); + } + + if (nifaces > 0) { + qemuAgentInterfaceFormatParams(ifaces, nifaces, list); + } + + if (format_load) { + virTypedParamListAddDouble(list, load1m, VIR_DOMAIN_GUEST_INFO_LOA= D_1M); + virTypedParamListAddDouble(list, load5m, VIR_DOMAIN_GUEST_INFO_LOA= D_5M); + virTypedParamListAddDouble(list, load15m, VIR_DOMAIN_GUEST_INFO_LO= AD_15M); + } + + if (virTypedParamListSteal(list, params, nparams) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + for (i =3D 0; i < nfs; i++) + qemuAgentFSInfoFree(agentfsinfo[i]); + g_free(agentfsinfo); + for (i =3D 0; i < ndisks; i++) + qemuAgentDiskInfoFree(agentdiskinfo[i]); + g_free(agentdiskinfo); + if (ifaces && nifaces > 0) { + for (i =3D 0; i < nifaces; i++) + virDomainInterfaceFree(ifaces[i]); + } + g_free(ifaces); + + virDomainObjEndAPI(&vm); + return ret; + + exitagent: + bhyveDomainObjExitAgent(vm, agent); + + endagentjob: + virDomainObjEndAgentJob(vm); + goto cleanup; +} + static virHypervisorDriver bhyveHypervisorDriver =3D { .name =3D "bhyve", .connectURIProbe =3D bhyveConnectURIProbe, @@ -2885,6 +3076,7 @@ static virHypervisorDriver bhyveHypervisorDriver =3D { .domainAuthorizedSSHKeysGet =3D bhyveDomainAuthorizedSSHKeysGet, /* 12= .6.0 */ .domainAuthorizedSSHKeysSet =3D bhyveDomainAuthorizedSSHKeysSet, /* 12= .6.0 */ .domainRename =3D bhyveDomainRename, /* 12.6.0 */ + .domainGetGuestInfo =3D bhyveDomainGetGuestInfo, /* 12.7.0 */ }; =20 =20 --=20 2.52.0