From patchwork Thu Apr 19 14:08:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasilis Liaskovitis X-Patchwork-Id: 153772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DE834B7007 for ; Fri, 20 Apr 2012 00:11:35 +1000 (EST) Received: from localhost ([::1]:36907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKs57-00020u-MG for incoming@patchwork.ozlabs.org; Thu, 19 Apr 2012 10:11:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKs3t-00009o-W4 for qemu-devel@nongnu.org; Thu, 19 Apr 2012 10:10:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SKs3i-0006D4-VX for qemu-devel@nongnu.org; Thu, 19 Apr 2012 10:10:17 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:46206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SKs3i-0005t5-LR for qemu-devel@nongnu.org; Thu, 19 Apr 2012 10:10:06 -0400 Received: by mail-bk0-f45.google.com with SMTP id ji1so416444bkc.4 for ; Thu, 19 Apr 2012 07:10:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=cS6MOiPmEk7unvrcLmFJ5ny/J78Nrc8sHfkw+sa6rcw=; b=CibuqTp9rnCeHhJ0p/1kYcZhxyCpGQYx2x3Bk4R/0zklINf5al8hqbxBEQD3quGp4S RYi08I/bSMAwiLgdQ18a5sAiAOOqkNRZnMVlS3F0UN6/vWy41faKhtTXvEjo+kejLcOJ L63NHJPgTq/HmkbzY48yUyuM/RLaN/K8klj5wR6z4WqyOeVD+K8/7XWhl0464UNGorcs P3WbQa4eu7cOO5RPq5I0pLM0lEhahpuYq52E28EovC2lXkIvLxGcdzufaOTq9/HUK3/m u6B0XLynNiLFLCWm35g4BuiSDta5EGX5+pPeacjwtXzL9IrzZvvDEmmxDQxMe1tNAC9K abEw== Received: by 10.204.153.3 with SMTP id i3mr711777bkw.45.1334844605642; Thu, 19 Apr 2012 07:10:05 -0700 (PDT) Received: from dhcp-192-168-178-175.ri.profitbricks.localdomain ([62.217.45.26]) by mx.google.com with ESMTPS id gu12sm4434954bkc.1.2012.04.19.07.10.05 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 19 Apr 2012 07:10:05 -0700 (PDT) From: Vasilis Liaskovitis To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org Date: Thu, 19 Apr 2012 16:08:45 +0200 Message-Id: <1334844527-18869-8-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1334844527-18869-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1334844527-18869-1-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Gm-Message-State: ALoCoQnQ6lZppGXpxonY/EuGrgqADNZdMrHGsxl8tz7K1bge6vXFWDhpPXAe4wzgEc8ut68z4FeJ X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.45 Cc: Vasilis Liaskovitis , avi@redhat.com, gleb@redhat.com Subject: [Qemu-devel] [RFC PATCH 7/9] Implement memslot command-line option and memslot hmp command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Implement -memslot qemu-kvm command line option to define hotplug-able memory slots. Syntax: "-memslot id=name,start=addr,size=sz,node=nodeid" e.g. "-memslot id=hot1,start=4294967296,size=1073741824,node=0" will define a 1G memory slot starting at physical address 4G, belonging to numa node 0. Defining no node will automatically add a memslot to node 0. Also implement a new hmp monitor command for hot-add and hot-remove of memory slots Syntax: "memslot slotname action" where action is add/delete and slotname is the qdev-id of the memory slot. Signed-off-by: Vasilis Liaskovitis --- Makefile.objs | 2 +- hmp-commands.hx | 15 +++++++++++++++ monitor.c | 8 ++++++++ monitor.h | 1 + qemu-config.c | 25 +++++++++++++++++++++++++ qemu-options.hx | 8 ++++++++ sysemu.h | 1 + vl.c | 40 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 99 insertions(+), 1 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index 5c3bcda..98ce865 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -240,7 +240,7 @@ hw-obj-$(CONFIG_USB_OHCI) += usb/hcd-ohci.o hw-obj-$(CONFIG_USB_EHCI) += usb/hcd-ehci.o hw-obj-$(CONFIG_USB_XHCI) += usb/hcd-xhci.o hw-obj-$(CONFIG_FDC) += fdc.o -hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o +hw-obj-$(CONFIG_ACPI) += acpi.o acpi_piix4.o memslot.o hw-obj-$(CONFIG_APM) += pm_smbus.o apm.o hw-obj-$(CONFIG_DMA) += dma.o hw-obj-$(CONFIG_I82374) += i82374.o diff --git a/hmp-commands.hx b/hmp-commands.hx index a6f5a84..cadf4ca 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -618,6 +618,21 @@ Add device. ETEXI { + .name = "memslot", + .args_type = "id:s,action:s", + .params = "id,action", + .help = "add memslot device", + .user_print = monitor_user_noop, + .mhandler.cmd_new = do_memslot_add, + }, + +STEXI +@item memslot_add @var{config} +@findex memslot_add + +Add memslot. +ETEXI + { .name = "device_del", .args_type = "id:s", .params = "device", diff --git a/monitor.c b/monitor.c index 8946a10..f672186 100644 --- a/monitor.c +++ b/monitor.c @@ -30,6 +30,7 @@ #include "hw/pci.h" #include "hw/watchdog.h" #include "hw/loader.h" +#include "hw/memslot.h" #include "gdbstub.h" #include "net.h" #include "net/slirp.h" @@ -4675,3 +4676,10 @@ int monitor_read_block_device_key(Monitor *mon, const char *device, return monitor_read_bdrv_key_start(mon, bs, completion_cb, opaque); } + +int do_memslot_add(Monitor *mon, const QDict *qdict, QObject **ret_data) +{ +#if defined(TARGET_I386) || defined(TARGET_X86_64) + return memslot_do(mon, qdict); +#endif +} diff --git a/monitor.h b/monitor.h index 0d49800..1e14a63 100644 --- a/monitor.h +++ b/monitor.h @@ -80,5 +80,6 @@ int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, int qmp_qom_set(Monitor *mon, const QDict *qdict, QObject **ret); int qmp_qom_get(Monitor *mon, const QDict *qdict, QObject **ret); +int do_memslot_add(Monitor *mon, const QDict *qdict, QObject **ret_data); #endif /* !MONITOR_H */ diff --git a/qemu-config.c b/qemu-config.c index be84a03..1f26187 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -613,6 +613,30 @@ QemuOptsList qemu_boot_opts = { }, }; +static QemuOptsList qemu_memslot_opts = { + .name = "memslot", + .head = QTAILQ_HEAD_INITIALIZER(qemu_memslot_opts.head), + .desc = { + { + .name = "id", + .type = QEMU_OPT_STRING, + },{ + .name = "start", + .type = QEMU_OPT_SIZE, + .help = "physical address start for this memslot", + },{ + .name = "size", + .type = QEMU_OPT_SIZE, + .help = "memory size for this memslot", + },{ + .name = "node", + .type = QEMU_OPT_NUMBER, + .help = "NUMA node number (i.e. proximity) for this memslot", + }, + { /* end of list */ } + }, +}; + static QemuOptsList *vm_config_groups[32] = { &qemu_drive_opts, &qemu_chardev_opts, @@ -628,6 +652,7 @@ static QemuOptsList *vm_config_groups[32] = { &qemu_machine_opts, &qemu_boot_opts, &qemu_iscsi_opts, + &qemu_memslot_opts, NULL, }; diff --git a/qemu-options.hx b/qemu-options.hx index a169792..aff0546 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2728,3 +2728,11 @@ HXCOMM This is the last statement. Insert new options before this line! STEXI @end table ETEXI + +DEF("memslot", HAS_ARG, QEMU_OPTION_memslot, + "-memslot start=num,size=num,id=name\n" + "specify unpopulated memory slot", + QEMU_ARCH_ALL) + + + diff --git a/sysemu.h b/sysemu.h index bc2c788..7247099 100644 --- a/sysemu.h +++ b/sysemu.h @@ -136,6 +136,7 @@ extern QEMUClock *rtc_clock; extern int nb_numa_nodes; extern uint64_t node_mem[MAX_NODES]; extern uint64_t node_cpumask[MAX_NODES]; +extern int nb_hp_memslots; #define MAX_OPTION_ROMS 16 typedef struct QEMUOptionRom { diff --git a/vl.c b/vl.c index 50df453..85ac0f9 100644 --- a/vl.c +++ b/vl.c @@ -126,6 +126,7 @@ int main(int argc, char **argv) #include "hw/xen.h" #include "hw/qdev.h" #include "hw/loader.h" +#include "hw/memslot.h" #include "bt-host.h" #include "net.h" #include "net/slirp.h" @@ -247,6 +248,7 @@ QTAILQ_HEAD(, FWBootEntry) fw_boot_order = QTAILQ_HEAD_INITIALIZER(fw_boot_order int nb_numa_nodes; uint64_t node_mem[MAX_NODES]; uint64_t node_cpumask[MAX_NODES]; +int nb_hp_memslots; uint8_t qemu_uuid[16]; @@ -512,6 +514,36 @@ static void configure_rtc_date_offset(const char *startdate, int legacy) } } +static void configure_memslot(QemuOpts *opts) +{ + const char *value, *id; + uint64_t start, size, node; + + id = qemu_opts_id(opts); + value = qemu_opt_get(opts, "start"); + if (!value) { + fprintf(stderr, "qemu: invalid start address for memslot '%s'\n", id); + exit(1); + } + start = atoll(value); + value = qemu_opt_get(opts, "size"); + if (!value) { + fprintf(stderr, "qemu: invalid size for memslot '%s'\n", id); + exit(1); + } + size = atoi(value); + value = qemu_opt_get(opts, "node"); + if (!value) { + fprintf(stderr, "qemu: no node proximity defined for memslot '%s'\n", id); + node = 0; + } + else node = atoi(value); + fprintf(stderr, "qemu: memslot %s start %lu size %lu node %lu \n", id, + start, size, node); + memslot_create((char*)id, start, size, node, nb_hp_memslots); + nb_hp_memslots++; +} + static void configure_rtc(QemuOpts *opts) { const char *value; @@ -2330,6 +2362,7 @@ int main(int argc, char **argv, char **envp) nb_numa_nodes = 0; nb_nics = 0; + nb_hp_memslots = 0; autostart= 1; @@ -2521,6 +2554,13 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_kernel: qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg); break; + case QEMU_OPTION_memslot: + opts = qemu_opts_parse(qemu_find_opts("memslot"), optarg, 0); + if (!opts) { + exit(1); + } + configure_memslot(opts); + break; case QEMU_OPTION_initrd: qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg); break;