From nobody Mon Feb 9 01:21:50 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1584347811; cv=none; d=zohomail.com; s=zohoarc; b=jLLVtUvg/0K/wodriuOGtU8leMD2Mw4xeyXQdDcyfe7LSGWhelWHRCKXOjmk7UYLoJYWZD5NKuhAeyESOLw48hESyhD9N3QGH/GlYG/TO4w9TTNnjF+8vojTuAxS0zjux2VSYg9Jjorq2Pvzm3z5M8actOhhtcZhkcHcxJTiZkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584347811; h=Content-Type:Content-Transfer-Encoding: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; bh=+08kKHPQ3g6FLqr4CEP3rmdOO9RwLXURR98Ri47VMM4=; b=P/0wp+etc2H0ZAvBiNOaZY7lzlQgMyTiVZgsqhjGZxlCtcpOucXSWFFMzaXp53/ItGOsZfnGFHWF31ITY58Qxhxt6tAGJshQcoqnQYsdqfUi2sYY24vBR4svZ0m5QabpR00lJylso3Hn/Zy1DQqJw3/p1LDhVt41Rp/hJU1arA8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1584347811032800.1680846606992; Mon, 16 Mar 2020 01:36:51 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-472-boL9oy3yPmmityXLsLPesg-1; Mon, 16 Mar 2020 04:36:47 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57999101FC65; Mon, 16 Mar 2020 08:36:42 +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 1F9261001DF0; Mon, 16 Mar 2020 08:36: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 AFFF386FF7; Mon, 16 Mar 2020 08:36:41 +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 02G8a8dN026238 for ; Mon, 16 Mar 2020 04:36:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id ACE0160BFB; Mon, 16 Mar 2020 08:36:08 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32D4E60BF3 for ; Mon, 16 Mar 2020 08:36:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584347809; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+08kKHPQ3g6FLqr4CEP3rmdOO9RwLXURR98Ri47VMM4=; b=B49HbXQfyBgfL5IwxZAqQB2SoRnrUzdwbbLb4BQ0ez1KryiI5yQr3N0UP64yodq8kbeycw 3kxkkzDnV+X4lHNhGlE95UzbBDnIh/Q+ZXiT1vD3OuC8oXZsEmOlpVm/9zQZrtKD0s1Ve2 sB7tiYlmCel+S7kTRbDynfA5Pr81WGo= X-MC-Unique: boL9oy3yPmmityXLsLPesg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/12] qemuAgentGetHostname: expose 'report_unsupported' argument Date: Mon, 16 Mar 2020 09:35:49 +0100 Message-Id: <27ffcfe6ddd60fb0380a1f3249104854d47fb3dd.1584347691.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com 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: , 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-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use qemuAgentCommandFull in qemuAgentGetHostname so that we can suppress error reports if the caller will not require them. Callers for now always require error reporting but will be fixed later. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_agent.c | 22 +++++++++++++++------- src/qemu/qemu_agent.h | 3 ++- src/qemu/qemu_driver.c | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 07aba2b45d..7de1fe496a 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1716,24 +1716,32 @@ qemuAgentUpdateCPUInfo(unsigned int nvcpus, } +/** + * qemuAgentGetHostname: + * + * Gets the guest hostname using the guest agent. + * + * Returns 0 on success and fills @hostname. On error -1 is returned with = an + * error reported and if '@report_unsupported' is false -2 is returned if = the + * guest agent does not support the command without reporting an error + */ int qemuAgentGetHostname(qemuAgentPtr agent, - char **hostname) + char **hostname, + bool report_unsupported) { g_autoptr(virJSONValue) cmd =3D qemuAgentMakeCommand("guest-get-host-n= ame", NULL); g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr data =3D NULL; const char *result =3D NULL; + int rc; if (!cmd) return -1; - if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) { - if (qemuAgentErrorCommandUnsupported(reply)) - return -2; - - return -1; - } + if ((rc =3D qemuAgentCommandFull(agent, cmd, &reply, agent->timeout, + report_unsupported)) < 0) + return rc; if (!(data =3D virJSONValueObjectGet(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h index 67fe9fcde9..7cf38d7091 100644 --- a/src/qemu/qemu_agent.h +++ b/src/qemu/qemu_agent.h @@ -129,7 +129,8 @@ int qemuAgentUpdateCPUInfo(unsigned int nvcpus, int qemuAgentGetHostname(qemuAgentPtr mon, - char **hostname); + char **hostname, + bool report_unsupported); int qemuAgentGetTime(qemuAgentPtr mon, long long *seconds, diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f9a4cc2758..5e1f3efa7d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20128,7 +20128,7 @@ qemuDomainGetHostnameAgent(virQEMUDriverPtr driver, goto endjob; agent =3D qemuDomainObjEnterAgent(vm); - ignore_value(qemuAgentGetHostname(agent, hostname)); + ignore_value(qemuAgentGetHostname(agent, hostname, true)); qemuDomainObjExitAgent(vm, agent); ret =3D 0; @@ -22922,7 +22922,7 @@ qemuDomainGetGuestInfo(virDomainPtr dom, goto exitagent; } if (supportedTypes & VIR_DOMAIN_GUEST_INFO_HOSTNAME) { - rc =3D qemuAgentGetHostname(agent, &hostname); + rc =3D qemuAgentGetHostname(agent, &hostname, true); if (rc < 0 && !(rc =3D=3D -2 && types =3D=3D 0)) goto exitagent; } --=20 2.24.1