From nobody Fri Dec 19 17:38:47 2025 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=1561391965; cv=none; d=zoho.com; s=zohoarc; b=D2nYADaq7mHZuAH95jdQiSWCivTVC1/n1IWmml2ZVLv1hApYGAhP4HZFia8qjGs/0k2B8i6/FFAOVexgpLWDgdm8SJGU9t5hv/rQzlGOfeSwYwz6wiuzI9F8XcYnKjLMRKpfhOrBFnPjtUnks21zczeZPSRl72KuyXzoShiXpRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391965; 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:ARC-Authentication-Results; bh=XMTWyqNdqu4nUS91YSF33WDwyAn5ckPXCDRelk6LrA8=; b=RNvL27mK36rfrt2QWN0T9py+vI/0SHbjizuhQE2rjf5APsm+V6VszxxBHxdYi71p29E+k9MFVmIIdfxaz6MN+kM8MeocWdnR5VF5Y6oFyv1Lfgp8wgrzBxllEgwcl99djFshfOJI2Oxhg2ahedQHUXbuueqJ9+EK9Ka7fCeg/Lc= 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 1561391965387922.0237221809931; Mon, 24 Jun 2019 08:59:25 -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 C4EC130872EE; Mon, 24 Jun 2019 15:59:23 +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 7DD381001B05; Mon, 24 Jun 2019 15:59:22 +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 36F35206D2; Mon, 24 Jun 2019 15:59:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5OFt73u014692 for ; Mon, 24 Jun 2019 11:55:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 159A41001B19; Mon, 24 Jun 2019 15:55:07 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 953961001B04 for ; Mon, 24 Jun 2019 15:55:06 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:54:56 +0200 Message-Id: <98c17764ee063a5738f4ad8b8b60cf56d1730906.1561391499.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 9/9] qemu: monitor: Add APIs for 'blockdev-create' 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.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.47]); Mon, 24 Jun 2019 15:59:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The 'blockdev-create' starts a job which creates a storage volume using the given protocol or formats an existing (added) volume with one of the supported storage formats. This patch adds the monitor interaction bits. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_monitor.c | 30 ++++++++++++++++++++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 26 ++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 5 +++++ 4 files changed, 65 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 9358d0b1e2..90cd5ea9bd 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4418,6 +4418,36 @@ qemuMonitorSetWatchdogAction(qemuMonitorPtr mon, } +/** + * qemuMonitorBlockdevCreate: + * @mon: monitor object + * @jobname: name of the job + * @props: JSON object describing the blockdev to add + * + * Instructs qemu to create/format a new stroage or format layer. Note that + * the job does not add the created/formatted image into qemu and + * qemuMonitorBlockdevAdd needs to be called separately with corresponding + * arguments. Note that the argumetns for creating and adding are differen= t. + * + * Note that @props is always consumed by this function and should not be + * accessed after calling this function. + */ +int +qemuMonitorBlockdevCreate(qemuMonitorPtr mon, + const char *jobname, + virJSONValuePtr props) +{ + VIR_DEBUG("jobname=3D%s props=3D%p", jobname, props); + + QEMU_CHECK_MONITOR_GOTO(mon, error); + + return qemuMonitorJSONBlockdevCreate(mon, jobname, props); + + error: + virJSONValueFree(props); + return -1; +} + /** * qemuMonitorBlockdevAdd: * @mon: monitor object diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index c6dddd1e9e..aafea6350c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1289,6 +1289,10 @@ virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemu= MonitorPtr mon); int qemuMonitorSetWatchdogAction(qemuMonitorPtr mon, const char *action); +int qemuMonitorBlockdevCreate(qemuMonitorPtr mon, + const char *jobname, + virJSONValuePtr props); + int qemuMonitorBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr props); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 04538bc46c..22fbd84e90 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8616,6 +8616,32 @@ qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mon, } +int +qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon, + const char *jobname, + virJSONValuePtr props) +{ + VIR_AUTOPTR(virJSONValue) cmd =3D NULL; + VIR_AUTOPTR(virJSONValue) reply =3D NULL; + + cmd =3D qemuMonitorJSONMakeCommand("blockdev-create", + "s:job-id", jobname, + "a:options", &props, + NULL); + virJSONValueFree(props); + if (!cmd) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + return 0; +} + + int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr props) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index a50d4d7b23..00e6b3d68f 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -580,6 +580,11 @@ int qemuMonitorJSONSetWatchdogAction(qemuMonitorPtr mo= n, const char *action) ATTRIBUTE_NONNULL(1); +int qemuMonitorJSONBlockdevCreate(qemuMonitorPtr mon, + const char *jobname, + virJSONValuePtr props) + ATTRIBUTE_NONNULL(1); + int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr props) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list