From patchwork Thu Mar 7 07:22:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 10842343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFC6217E4 for ; Thu, 7 Mar 2019 07:52:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D8592E9A0 for ; Thu, 7 Mar 2019 07:52:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9064E2E9EE; Thu, 7 Mar 2019 07:52:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0AC582E9A0 for ; Thu, 7 Mar 2019 07:52:49 +0000 (UTC) Received: from localhost ([127.0.0.1]:47032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1nph-0002LE-7R for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 02:52:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60320) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1nMs-000329-C6 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:23:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1nMr-0006Zl-01 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:23:02 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:56382) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1nMq-0006Z4-JP for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:23:00 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x277JK9o037932; Thu, 7 Mar 2019 07:22:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=mGjpMEfyTgWJNDfl6nQF6Y/MKVNzmDs9+vygYsGtLy8=; b=S24TaDUuZZxmjjKjlqfJZWBDAEJm6TqxegtT100eUNjJ5uZU8ECRpk5F5RZADgL/SYfb HN2siRpejKnxQ+AgystT3cQm3Tfvg36FyDKWldZE8bS8WySh3x6k9IZPgJcYTL2Y+/d5 JmmyV5cPJC5k60T7U3zewSArQeNfIxpLc8brVigK0oYemNu1QxRPhhPf9VZIs1PShkPL oDNYo/qKC/rcCDCm9gZH7PE2/DtNuuZjxXhOL32Y79ZddE5fAFZx1B1CgNk8sPk86odf 1o1iVDFCwNFucZ4bFe++LlN+D4A6cyNrD6MSjs0bZKuxIA4K0aaa+3GhNXkq4gzdNjjN iQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2qyjfrr5gp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Mar 2019 07:22:56 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x277MpUj002572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Mar 2019 07:22:51 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x277MoIa011964; Thu, 7 Mar 2019 07:22:50 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Mar 2019 23:22:50 -0800 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Wed, 6 Mar 2019 23:22:48 -0800 Message-Id: <20190307072248.9778-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9187 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903070053 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [multiprocess RFC PATCH 34/37] multi-process: HMP command to delete drive from remote device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: elena.ufimtseva@oracle.com, john.g.johnson@oracle.com, sstabellini@kernel.org, jag.raman@oracle.com, konrad.wilk@oracle.com, dgilbert@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Add rdrive_del HMP command to hot-unplug drive from remote device. Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson --- hmp-commands.hx | 14 ++++++++++++++ hw/proxy/monitor.c | 37 +++++++++++++++++++++++++++++++++++++ include/io/proxy-link.h | 2 ++ include/sysemu/blockdev.h | 1 + remote/remote-main.c | 18 ++++++++++++++++++ 5 files changed, 72 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 3829203..510fc24 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1415,6 +1415,20 @@ STEXI @findex rdrive_add Add drive to remote PCI storage controller. ETEXI + + { + .name = "rdrive_del", + .args_type = "rdev_id:s,id:s", + .params = "rdev_id id", + .help = "remove drive from remote PCI storage controller", + .cmd = hmp_rdrive_del, + }, + +STEXI +@item rdrive_del +@findex rdrive_del +Remove drive from remote PCI storage controller +ETEXI #endif { diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c index ead1e3d..aa09ea8 100644 --- a/hw/proxy/monitor.c +++ b/hw/proxy/monitor.c @@ -42,6 +42,7 @@ #include "qapi/error.h" #include "io/proxy-link.h" #include "sysemu/sysemu.h" +#include "sysemu/blockdev.h" /* * TODO: Is there a callback where the allocated memory for QMP could be free'd @@ -246,3 +247,39 @@ void hmp_rdrive_add(Monitor *mon, const QDict *qdict) g_free(data); } +void hmp_rdrive_del(Monitor *mon, const QDict *qdict) +{ + PCMachineState *pcms = PC_MACHINE(current_machine); + Error *local_err = NULL; + ProcMsg msg = {0}; + PCIProxyDev *pdev = NULL; + const char *id; + int wait; + + pdev = get_proxy_device((QDict *)qdict, &local_err); + if (local_err) { + monitor_printf(mon, "rdrive_del error: %s\n", + error_get_pretty(local_err)); + error_free(local_err); + return; + } + + id = qdict_get_str(qdict, "id"); + + wait = GET_REMOTE_WAIT; + + msg.cmd = DRIVE_DEL; + msg.bytestream = 1; + msg.size = strlen(id); + msg.data2 = (uint8_t *)id; + msg.num_fds = 1; + msg.fds[0] = wait; + + proxy_proc_send(pdev->proxy_link, &msg); + (void)wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + + /* TODO: Only on success */ + (void)g_hash_table_remove(pcms->remote_devs, (gpointer)id); +} + diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 3ef16f1..013a845 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -63,6 +63,7 @@ typedef struct ProxyLinkState ProxyLinkState; * DEVICE_ADD QMP/HMP command to hotplug device * DEVICE_DEL QMP/HMP command to hot-unplug device * DRIVE_ADD HMP command to hotplug drive + * DRIVE_DEL HMP command to hot-unplug drive * */ typedef enum { @@ -78,6 +79,7 @@ typedef enum { DEVICE_ADD, DEVICE_DEL, DRIVE_ADD, + DRIVE_DEL, PROXY_PING, MAX, } proc_cmd_t; diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index d34c492..e6a9780 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -61,4 +61,5 @@ DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type, void hmp_commit(Monitor *mon, const QDict *qdict); void hmp_drive_del(Monitor *mon, const QDict *qdict); +void hmp_rdrive_del(Monitor *mon, const QDict *qdict); #endif diff --git a/remote/remote-main.c b/remote/remote-main.c index 4c52d30..08e3528 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -257,6 +257,21 @@ static void process_drive_add_msg(ProcMsg *msg) PUT_REMOTE_WAIT(wait); } +static void process_drive_del_msg(ProcMsg *msg) +{ + const char *idstr = (const char *)msg->data2; + int wait = msg->fds[0]; + QDict *qdict = qdict_new(); + + qdict_put_str(qdict, "id", idstr); + + hmp_drive_del(NULL, qdict); + + notify_proxy(wait, 1); + + PUT_REMOTE_WAIT(wait); +} + static int init_drive(QDict *rqdict, Error **errp) { QemuOpts *opts; @@ -445,6 +460,9 @@ static void process_msg(GIOCondition cond) case DRIVE_ADD: process_drive_add_msg(msg); break; + case DRIVE_DEL: + process_drive_del_msg(msg); + break; case PROXY_PING: wait = msg->fds[0]; notify_proxy(wait, (uint32_t)getpid());