From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 823EBC4361B for ; Wed, 9 Dec 2020 21:32:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CCBB423A02 for ; Wed, 9 Dec 2020 21:32:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCBB423A02 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn74l-0003VO-8I for qemu-devel@archiver.kernel.org; Wed, 09 Dec 2020 16:32:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn71B-0002OR-Ok for qemu-devel@nongnu.org; Wed, 09 Dec 2020 16:29:01 -0500 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:36020) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kn718-0001x5-Gs for qemu-devel@nongnu.org; Wed, 09 Dec 2020 16:29:01 -0500 Received: by mail-ed1-x543.google.com with SMTP id b2so3223580edm.3 for ; Wed, 09 Dec 2020 13:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oS+fUiPiQIRlzerKyCSUKf5efXvgFTPX8LWoZPkKrPw=; b=bNXxb2Vg1SPZt0gT1EtKGyXPZyexbeoxxT1KW+8PJAxfCb4Ai/WkQ0DMqk/WTIvJpV sRfKSuj//pKSBUL4MH5np9Y2F9mwO2fdo2g7hJ6OaAguDdsuVBJSEsuD0uOUP4g0OS2z yoki1FkF+Hy7AycvpBwVBoCH3RZmFsiIC+dNCwrgLQxA4R7cf3azGtisFkWo7E+z6I+P cXikaez8J03EvrnHL7Ok0CoEjfAiTj6Cx5/U15tmm7JGMWiDAIo/br9uRL7qVJcOgnhW G6Z54brqh0IzuZ8L2pHvCDknP8VDibzhHNsAo96SjF1V7x2gynSTaKCdZripMD0q93iQ Sh3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oS+fUiPiQIRlzerKyCSUKf5efXvgFTPX8LWoZPkKrPw=; b=bHKjBizMpcodlGMUFkVAi20fOiZsHljL+pHxNpzms1BnrzrHLq1KfO8HTqiE27Dh7Y TOx7CYdBCtBmSt0//lGKaNiWg6OYCQ0OPSlQ2Xndf0EUCpYMXNkk2DL2OtezWjFUVxNK 1hL3Tzlp1igK9j/K4WsMvdU/eC9dMhvdPiI7e57+iM8n0XJE+gNA0/TxO+lvRf9BnuTU Ww39hU6djBqIQMN2snKsNsQpOgd7s+/NnE2NMf9AB8zkwKr5TX+a/5pW3e2fzx0cE01M Vfpu6ml8SKlYgKhAD2zjEMg6eGg5xIqHRCzxs60ds7eo1O7qo9mIrgxt9+2icHoGxn6P PIbw== X-Gm-Message-State: AOAM531pdomrEsnBnCBOifrFLujSKnUPNBlNaJUdfj8DMLvI4Ln2/x9R sucvAdO0pKdEvD1mY5kzi8Wx0Wg1L1fhwWBzv7c= X-Google-Smtp-Source: ABdhPJy7ygw3w2vyFU7prxiF+zPgxtBrX1L/i0qWQG1Vx+O9dXGXookE/LDjSDrAYlrkEqfYT3Nf8Z4+HrLudOI44/g= X-Received: by 2002:a05:6402:1155:: with SMTP id g21mr3987400edw.53.1607549336382; Wed, 09 Dec 2020 13:28:56 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Thu, 10 Dec 2020 01:28:44 +0400 Message-ID: Subject: Re: [PATCH v12 16/19] multi-process: Synchronize remote memory To: Jag Raman Content-Type: multipart/alternative; boundary="00000000000027715805b60ebf31" Received-SPF: pass client-ip=2a00:1450:4864:20::543; envelope-from=marcandre.lureau@gmail.com; helo=mail-ed1-x543.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Elena Ufimtseva , Fam Zheng , Swapnil Ingle , John G Johnson , QEMU , Gerd Hoffmann , Juan Quintela , "Michael S. Tsirkin" , Markus Armbruster , Kanth Ghatraju , Felipe Franciosi , Thomas Huth , Eduardo Habkost , Konrad Rzeszutek Wilk , "Dr. David Alan Gilbert" , Alex Williamson , Stefan Hajnoczi , Paolo Bonzini , Richard Henderson , Kevin Wolf , "Daniel P. Berrange" , Max Reitz , Ross Lagerwall , Thanos Makatos Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --00000000000027715805b60ebf31 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 9, 2020 at 8:20 PM Jag Raman wrote: > > > > On Dec 8, 2020, at 8:57 AM, Marc-Andr=C3=A9 Lureau < > marcandre.lureau@gmail.com> wrote: > > > > Hi > > > > On Wed, Dec 2, 2020 at 12:23 AM Jagannathan Raman > wrote: > > Add memory-listener object which is used to keep the view of the RAM > > in sync between QEMU and remote process. > > A MemoryListener is registered for system-memory AddressSpace. The > > listener sends SYNC_SYSMEM message to the remote process when memory > > listener commits the changes to memory, the remote process receives > > the message and processes it in the handler for SYNC_SYSMEM message. > > > > Signed-off-by: Jagannathan Raman > > Signed-off-by: John G Johnson > > Signed-off-by: Elena Ufimtseva > > Reviewed-by: Stefan Hajnoczi > > --- > > include/hw/remote/memory-sync.h | 27 ++++++ > > include/hw/remote/proxy.h | 2 + > > hw/remote/memory-sync.c | 210 > ++++++++++++++++++++++++++++++++++++++++ > > hw/remote/message.c | 5 + > > hw/remote/proxy.c | 6 ++ > > MAINTAINERS | 2 + > > hw/remote/meson.build | 1 + > > 7 files changed, 253 insertions(+) > > create mode 100644 include/hw/remote/memory-sync.h > > create mode 100644 hw/remote/memory-sync.c > > > > diff --git a/include/hw/remote/memory-sync.h > b/include/hw/remote/memory-sync.h > > new file mode 100644 > > index 0000000..785f76a > > --- /dev/null > > +++ b/include/hw/remote/memory-sync.h > > @@ -0,0 +1,27 @@ > > +/* > > + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. > > + * > > + * This work is licensed under the terms of the GNU GPL, version 2 or > later. > > + * See the COPYING file in the top-level directory. > > + * > > + */ > > + > > +#ifndef MEMORY_SYNC_H > > +#define MEMORY_SYNC_H > > + > > +#include "exec/memory.h" > > +#include "io/channel.h" > > + > > +typedef struct RemoteMemSync { > > + MemoryListener listener; > > + > > + int n_mr_sections; > > + MemoryRegionSection *mr_sections; > > + > > + QIOChannel *ioc; > > +} RemoteMemSync; > > + > > +void configure_memory_sync(RemoteMemSync *sync, QIOChannel *ioc); > > +void deconfigure_memory_sync(RemoteMemSync *sync); > > > > RemoteMemSync vs MemorySync, and function with _memory_sync suffixes... > > Naming things is hard, but trying to be consistent generally helps. > > > > My understanding is that this is a proxy-dev helper to handle memory > listening and sending SYNC_SYSMEM. > > > > I would thus suggest naming it ProxyMemoryListener. It could eventually > be folded in proxy.c > > > > Please try to be consistent with header naming, structure naming, type, > functions and enum prefixes etc. > > > > proxy_memory_listener isn't that long imho. > > > > + > > +#endif > > diff --git a/include/hw/remote/proxy.h b/include/hw/remote/proxy.h > > index e29c61b..a687b7d 100644 > > --- a/include/hw/remote/proxy.h > > +++ b/include/hw/remote/proxy.h > > @@ -11,6 +11,7 @@ > > > > #include "hw/pci/pci.h" > > #include "io/channel.h" > > +#include "hw/remote/memory-sync.h" > > > > #define TYPE_PCI_PROXY_DEV "x-pci-proxy-dev" > > > > @@ -40,6 +41,7 @@ struct PCIProxyDev { > > QemuMutex io_mutex; > > QIOChannel *ioc; > > Error *migration_blocker; > > + RemoteMemSync sync; > > ProxyMemoryRegion region[PCI_NUM_REGIONS]; > > }; > > > > diff --git a/hw/remote/memory-sync.c b/hw/remote/memory-sync.c > > new file mode 100644 > > index 0000000..2365e69 > > --- /dev/null > > +++ b/hw/remote/memory-sync.c > > @@ -0,0 +1,210 @@ > > +/* > > + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. > > + * > > + * This work is licensed under the terms of the GNU GPL, version 2 or > later. > > + * See the COPYING file in the top-level directory. > > + * > > + */ > > + > > +#include "qemu/osdep.h" > > +#include "qemu-common.h" > > + > > +#include "qemu/compiler.h" > > +#include "qemu/int128.h" > > +#include "qemu/range.h" > > +#include "exec/memory.h" > > +#include "exec/cpu-common.h" > > +#include "cpu.h" > > +#include "exec/ram_addr.h" > > +#include "exec/address-spaces.h" > > +#include "hw/remote/mpqemu-link.h" > > +#include "hw/remote/memory-sync.h" > > + > > +static void proxy_ml_begin(MemoryListener *listener) > > > > I suggest to rename begin -> reset > > > > +{ > > + RemoteMemSync *sync =3D container_of(listener, RemoteMemSync, > listener); > > + int mrs; > > + > > + for (mrs =3D 0; mrs < sync->n_mr_sections; mrs++) { > > + memory_region_unref(sync->mr_sections[mrs].mr); > > + } > > + > > + g_free(sync->mr_sections); > > + sync->mr_sections =3D NULL; > > + sync->n_mr_sections =3D 0; > > +} > > + > > +static int get_fd_from_hostaddr(uint64_t host, ram_addr_t *offset) > > > > This function is very similar to vhost_user_get_mr_data(). That suggest= s > we could factor the code. > > > > Perhaps a new memory_region_from_host_full(), or extend > memory_region_from_host() with an extra optional "int *fd" argument. > > > > +{ > > + MemoryRegion *mr; > > + ram_addr_t off; > > + > > + /** > > + * Assumes that the host address is a valid address as it's > > + * coming from the MemoryListener system. In the case host > > + * address is not valid, the following call would return > > + * the default subregion of "system_memory" region, and > > + * not NULL. So it's not possible to check for NULL here. > > + */ > > + mr =3D memory_region_from_host((void *)(uintptr_t)host, &off); > > + > > + if (offset) { > > + *offset =3D off; > > + } > > + > > + return memory_region_get_fd(mr); > > +} > > + > > +static bool proxy_mrs_can_merge(uint64_t host, uint64_t prev_host, > size_t size) > > +{ > > > > This seems similar to vhost_user_can_merge(). > > > > + bool merge; > > + int fd1, fd2; > > + > > + fd1 =3D get_fd_from_hostaddr(host, NULL); > > + > > + fd2 =3D get_fd_from_hostaddr(prev_host, NULL); > > + > > + merge =3D (fd1 =3D=3D fd2); > > > > This could be written in a simpler manner, ex: > > > > if (get_fd_from_hostaddr(host, NULL) !=3D get_fd_from_hostaddr(prev_hos= t, > NULL)) > > return false > > > > + > > + merge &=3D ((prev_host + size) =3D=3D host); > > > > That check could be done early on before doing the more expensive > memory_region_from_host() calls > > > > + > > + return merge; > > +} > > + > > +static bool try_merge(RemoteMemSync *sync, MemoryRegionSection *sectio= n) > > +{ > > + uint64_t mrs_size, mrs_gpa, mrs_page; > > + MemoryRegionSection *prev_sec; > > + bool merged =3D false; > > + uintptr_t mrs_host; > > + RAMBlock *mrs_rb; > > + > > + if (!sync->n_mr_sections) { > > + return false; > > + } > > + > > + mrs_rb =3D section->mr->ram_block; > > + mrs_page =3D (uint64_t)qemu_ram_pagesize(mrs_rb); > > + mrs_size =3D int128_get64(section->size); > > + mrs_gpa =3D section->offset_within_address_space; > > + mrs_host =3D (uintptr_t)memory_region_get_ram_ptr(section->mr) + > > + section->offset_within_region; > > + > > + if (get_fd_from_hostaddr(mrs_host, NULL) < 0) { > > + return true; > > + } > > + > > + mrs_host =3D mrs_host & ~(mrs_page - 1); > > + mrs_gpa =3D mrs_gpa & ~(mrs_page - 1); > > + mrs_size =3D ROUND_UP(mrs_size, mrs_page); > > + > > + prev_sec =3D sync->mr_sections + (sync->n_mr_sections - 1); > > + uint64_t prev_gpa_start =3D prev_sec->offset_within_address_space; > > + uint64_t prev_size =3D int128_get64(prev_sec->size); > > + uint64_t prev_gpa_end =3D range_get_last(prev_gpa_start, prev_si= ze); > > + uint64_t prev_host_start =3D > > + (uintptr_t)memory_region_get_ram_ptr(prev_sec->mr) + > > + prev_sec->offset_within_region; > > + uint64_t prev_host_end =3D range_get_last(prev_host_start, prev_si= ze); > > + > > + if (mrs_gpa <=3D (prev_gpa_end + 1)) { > > + g_assert(mrs_gpa > prev_gpa_start); > > + > > + if ((section->mr =3D=3D prev_sec->mr) && > > + proxy_mrs_can_merge(mrs_host, prev_host_start, > > + (mrs_gpa - prev_gpa_start))) { > > + uint64_t max_end =3D MAX(prev_host_end, mrs_host + mrs_siz= e); > > + merged =3D true; > > + prev_sec->offset_within_address_space =3D > > + MIN(prev_gpa_start, mrs_gpa); > > + prev_sec->offset_within_region =3D > > + MIN(prev_host_start, mrs_host) - > > + (uintptr_t)memory_region_get_ram_ptr(prev_sec->mr); > > + prev_sec->size =3D int128_make64(max_end - > MIN(prev_host_start, > > + mrs_host)); > > + } > > + } > > + > > + return merged; > > +} > > + > > +static void proxy_ml_region_addnop(MemoryListener *listener, > > + MemoryRegionSection *section) > > +{ > > + RemoteMemSync *sync =3D container_of(listener, RemoteMemSync, > listener); > > + > > + if (!(memory_region_is_ram(section->mr) && > > + !memory_region_is_rom(section->mr))) { > > + return; > > > > A bit clearer in vhost.c: > > if (memory_region_is_ram(mr) && !memory_region_is_rom(mr)) { > > > > + } > > + > > + if (try_merge(sync, section)) { > > + return; > > + } > > + > > + ++sync->n_mr_sections; > > + sync->mr_sections =3D g_renew(MemoryRegionSection, sync->mr_sectio= ns, > > + sync->n_mr_sections); > > + sync->mr_sections[sync->n_mr_sections - 1] =3D *section; > > + sync->mr_sections[sync->n_mr_sections - 1].fv =3D NULL; > > + memory_region_ref(section->mr); > > +} > > + > > +static void proxy_ml_commit(MemoryListener *listener) > > +{ > > + RemoteMemSync *sync =3D container_of(listener, RemoteMemSync, > listener); > > + MPQemuMsg msg; > > + MemoryRegionSection *section; > > + ram_addr_t offset; > > + uintptr_t host_addr; > > + int region; > > + Error *local_err =3D NULL; > > + > > + memset(&msg, 0, sizeof(MPQemuMsg)); > > + > > + msg.cmd =3D SYNC_SYSMEM; > > + msg.num_fds =3D sync->n_mr_sections; > > + msg.size =3D sizeof(SyncSysmemMsg); > > + if (msg.num_fds > REMOTE_MAX_FDS) { > > + error_report("Number of fds is more than %d", REMOTE_MAX_FDS); > > + return; > > + } > > + > > + for (region =3D 0; region < sync->n_mr_sections; region++) { > > + section =3D &sync->mr_sections[region]; > > + msg.data.sync_sysmem.gpas[region] =3D > > + section->offset_within_address_space; > > + msg.data.sync_sysmem.sizes[region] =3D > int128_get64(section->size); > > + host_addr =3D (uintptr_t)memory_region_get_ram_ptr(section->mr= ) + > > + section->offset_within_region; > > + msg.fds[region] =3D get_fd_from_hostaddr(host_addr, &offset); > > + msg.data.sync_sysmem.offsets[region] =3D offset; > > + } > > + mpqemu_msg_send(&msg, sync->ioc, &local_err); > > + if (local_err) { > > + error_report("Error in sending command %d", msg.cmd); > > + } > > +} > > > > That whole complex code above duplicates much of the logic in vhost.c. > Can we try to factorize it instead? > > Hi Marc-Andre, > > Thank you for sharing your feedback! > > Would it be alright if we addressed this item alone in a separate patch i= n > the future? Since > this refactoring affects vhost code, we=E2=80=99re wondering it would be = better to > address it in a > future patch to help with any regression analysis in the future. > That's fine with me, but please leave a TODO note in the code then. thanks > Thank you! > =E2=80=94 > Jag > > > > > + > > +void deconfigure_memory_sync(RemoteMemSync *sync) > > +{ > > + memory_listener_unregister(&sync->listener); > > + > > + proxy_ml_begin(&sync->listener); > > +} > > + > > +void configure_memory_sync(RemoteMemSync *sync, QIOChannel *ioc) > > +{ > > + sync->n_mr_sections =3D 0; > > + sync->mr_sections =3D NULL; > > + > > + sync->ioc =3D ioc; > > + > > + sync->listener.begin =3D proxy_ml_begin; > > + sync->listener.commit =3D proxy_ml_commit; > > + sync->listener.region_add =3D proxy_ml_region_addnop; > > + sync->listener.region_nop =3D proxy_ml_region_addnop; > > + sync->listener.priority =3D 10; > > + > > + memory_listener_register(&sync->listener, &address_space_memory); > > +} > > diff --git a/hw/remote/message.c b/hw/remote/message.c > > index 0f3e38a..454fd2d 100644 > > --- a/hw/remote/message.c > > +++ b/hw/remote/message.c > > @@ -17,6 +17,7 @@ > > #include "sysemu/runstate.h" > > #include "hw/pci/pci.h" > > #include "exec/memattrs.h" > > +#include "hw/remote/memory.h" > > > > static void process_config_write(QIOChannel *ioc, PCIDevice *dev, > > MPQemuMsg *msg); > > @@ -64,6 +65,10 @@ void coroutine_fn mpqemu_remote_msg_loop_co(void > *data) > > case BAR_READ: > > process_bar_read(com->ioc, &msg, &local_err); > > break; > > + case SYNC_SYSMEM: > > + remote_sysmem_reconfig(&msg, &local_err); > > + break; > > + > > default: > > error_setg(&local_err, > > "Unknown command (%d) received for device %s > (pid=3D%d)", > > diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c > > index 039347d..0f2d1aa 100644 > > --- a/hw/remote/proxy.c > > +++ b/hw/remote/proxy.c > > @@ -18,6 +18,8 @@ > > #include "migration/blocker.h" > > #include "hw/remote/mpqemu-link.h" > > #include "qemu/error-report.h" > > +#include "hw/remote/memory-sync.h" > > +#include "qom/object.h" > > > > static void proxy_set_socket(PCIProxyDev *pdev, int fd, Error **errp) > > { > > @@ -58,6 +60,8 @@ static void pci_proxy_dev_realize(PCIDevice *device, > Error **errp) > > > > qemu_mutex_init(&dev->io_mutex); > > qio_channel_set_blocking(dev->ioc, true, NULL); > > + > > + configure_memory_sync(&dev->sync, dev->ioc); > > } > > > > static void pci_proxy_dev_exit(PCIDevice *pdev) > > @@ -69,6 +73,8 @@ static void pci_proxy_dev_exit(PCIDevice *pdev) > > migrate_del_blocker(dev->migration_blocker); > > > > error_free(dev->migration_blocker); > > + > > + deconfigure_memory_sync(&dev->sync); > > } > > > > static int config_op_send(PCIProxyDev *pdev, uint32_t addr, uint32_t > *val, > > diff --git a/MAINTAINERS b/MAINTAINERS > > index ebd1d1d..5d78b78 100644 > > --- a/MAINTAINERS > > +++ b/MAINTAINERS > > @@ -3150,6 +3150,8 @@ F: include/hw/remote/memory.h > > F: hw/remote/memory.c > > F: hw/remote/proxy.c > > F: include/hw/remote/proxy.h > > +F: hw/remote/memory-sync.c > > +F: include/hw/remote/memory-sync.h > > > > Build and test automation > > ------------------------- > > diff --git a/hw/remote/meson.build b/hw/remote/meson.build > > index 569cd20..7d434a5 100644 > > --- a/hw/remote/meson.build > > +++ b/hw/remote/meson.build > > @@ -7,5 +7,6 @@ remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: > files('remote-obj.c')) > > remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('proxy.c')) > > > > specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('memory.c'= )) > > +specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: > files('memory-sync.c')) > > > > softmmu_ss.add_all(when: 'CONFIG_MULTIPROCESS', if_true: remote_ss) > > -- > > 1.8.3.1 > > > > > > > > -- > > Marc-Andr=C3=A9 Lureau > > --=20 Marc-Andr=C3=A9 Lureau --00000000000027715805b60ebf31 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Dec 9, 2020 at 8:20 PM Jag Ra= man <jag.raman@oracle.com>= ; wrote:


> On Dec 8, 2020, at 8:57 AM, Marc-Andr=C3=A9 Lureau <marcandre.lureau@gmail.com= > wrote:
>
> Hi
>
> On Wed, Dec 2, 2020 at 12:23 AM Jagannathan Raman <jag.raman@oracle.com> wrot= e:
> Add memory-listener object which is used to keep the view of the RAM > in sync between QEMU and remote process.
> A MemoryListener is registered for system-memory AddressSpace. The
> listener sends SYNC_SYSMEM message to the remote process when memory > listener commits the changes to memory, the remote process receives > the message and processes it in the handler for SYNC_SYSMEM message. >
> Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
> Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
> Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>=C2=A0 include/hw/remote/memory-sync.h |=C2=A0 27 ++++++
>=C2=A0 include/hw/remote/proxy.h=C2=A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2= =A02 +
>=C2=A0 hw/remote/memory-sync.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 210 += +++++++++++++++++++++++++++++++++++++++
>=C2=A0 hw/remote/message.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0|=C2=A0 =C2=A05 +
>=C2=A0 hw/remote/proxy.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0|=C2=A0 =C2=A06 ++
>=C2=A0 MAINTAINERS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0|=C2=A0 =C2=A02 +
>=C2=A0 hw/remote/meson.build=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|= =C2=A0 =C2=A01 +
>=C2=A0 7 files changed, 253 insertions(+)
>=C2=A0 create mode 100644 include/hw/remote/memory-sync.h
>=C2=A0 create mode 100644 hw/remote/memory-sync.c
>
> diff --git a/include/hw/remote/memory-sync.h b/include/hw/remote/memor= y-sync.h
> new file mode 100644
> index 0000000..785f76a
> --- /dev/null
> +++ b/include/hw/remote/memory-sync.h
> @@ -0,0 +1,27 @@
> +/*
> + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates.
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or= later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#ifndef MEMORY_SYNC_H
> +#define MEMORY_SYNC_H
> +
> +#include "exec/memory.h"
> +#include "io/channel.h"
> +
> +typedef struct RemoteMemSync {
> +=C2=A0 =C2=A0 MemoryListener listener;
> +
> +=C2=A0 =C2=A0 int n_mr_sections;
> +=C2=A0 =C2=A0 MemoryRegionSection *mr_sections;
> +
> +=C2=A0 =C2=A0 QIOChannel *ioc;
> +} RemoteMemSync;
> +
> +void configure_memory_sync(RemoteMemSync *sync, QIOChannel *ioc);
> +void deconfigure_memory_sync(RemoteMemSync *sync);
>
> RemoteMemSync vs MemorySync, and function with _memory_sync suffixes..= .
> Naming things is hard, but trying to be consistent generally helps. >
> My understanding is that this is a proxy-dev helper to handle memory l= istening and sending SYNC_SYSMEM.
>
> I would thus suggest naming it ProxyMemoryListener. It could eventuall= y be folded in proxy.c
>
> Please try to be consistent with header naming, structure naming, type= , functions and enum prefixes etc.
>
> proxy_memory_listener isn't that long imho.
>
> +
> +#endif
> diff --git a/include/hw/remote/proxy.h b/include/hw/remote/proxy.h
> index e29c61b..a687b7d 100644
> --- a/include/hw/remote/proxy.h
> +++ b/include/hw/remote/proxy.h
> @@ -11,6 +11,7 @@
>
>=C2=A0 #include "hw/pci/pci.h"
>=C2=A0 #include "io/channel.h"
> +#include "hw/remote/memory-sync.h"
>
>=C2=A0 #define TYPE_PCI_PROXY_DEV "x-pci-proxy-dev"
>
> @@ -40,6 +41,7 @@ struct PCIProxyDev {
>=C2=A0 =C2=A0 =C2=A0 QemuMutex io_mutex;
>=C2=A0 =C2=A0 =C2=A0 QIOChannel *ioc;
>=C2=A0 =C2=A0 =C2=A0 Error *migration_blocker;
> +=C2=A0 =C2=A0 RemoteMemSync sync;
>=C2=A0 =C2=A0 =C2=A0 ProxyMemoryRegion region[PCI_NUM_REGIONS];
>=C2=A0 };
>
> diff --git a/hw/remote/memory-sync.c b/hw/remote/memory-sync.c
> new file mode 100644
> index 0000000..2365e69
> --- /dev/null
> +++ b/hw/remote/memory-sync.c
> @@ -0,0 +1,210 @@
> +/*
> + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates.
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or= later.
> + * See the COPYING file in the top-level directory.
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +
> +#include "qemu/compiler.h"
> +#include "qemu/int128.h"
> +#include "qemu/range.h"
> +#include "exec/memory.h"
> +#include "exec/cpu-common.h"
> +#include "cpu.h"
> +#include "exec/ram_addr.h"
> +#include "exec/address-spaces.h"
> +#include "hw/remote/mpqemu-link.h"
> +#include "hw/remote/memory-sync.h"
> +
> +static void proxy_ml_begin(MemoryListener *listener)
>
> I suggest to rename begin -> reset
>
> +{
> +=C2=A0 =C2=A0 RemoteMemSync *sync =3D container_of(listener, RemoteMe= mSync, listener);
> +=C2=A0 =C2=A0 int mrs;
> +
> +=C2=A0 =C2=A0 for (mrs =3D 0; mrs < sync->n_mr_sections; mrs++)= {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 memory_region_unref(sync->mr_sections[= mrs].mr);
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 g_free(sync->mr_sections);
> +=C2=A0 =C2=A0 sync->mr_sections =3D NULL;
> +=C2=A0 =C2=A0 sync->n_mr_sections =3D 0;
> +}
> +
> +static int get_fd_from_hostaddr(uint64_t host, ram_addr_t *offset) >
> This function is very similar to vhost_user_get_mr_data(). That sugges= ts we could factor the code.
>
> Perhaps a new memory_region_from_host_full(), or extend memory_region_= from_host() with an extra optional "int *fd" argument.
>=C2=A0
> +{
> +=C2=A0 =C2=A0 MemoryRegion *mr;
> +=C2=A0 =C2=A0 ram_addr_t off;
> +
> +=C2=A0 =C2=A0 /**
> +=C2=A0 =C2=A0 =C2=A0* Assumes that the host address is a valid addres= s as it's
> +=C2=A0 =C2=A0 =C2=A0* coming from the MemoryListener system. In the c= ase host
> +=C2=A0 =C2=A0 =C2=A0* address is not valid, the following call would = return
> +=C2=A0 =C2=A0 =C2=A0* the default subregion of "system_memory&qu= ot; region, and
> +=C2=A0 =C2=A0 =C2=A0* not NULL. So it's not possible to check for= NULL here.
> +=C2=A0 =C2=A0 =C2=A0*/
> +=C2=A0 =C2=A0 mr =3D memory_region_from_host((void *)(uintptr_t)host,= &off);
> +
> +=C2=A0 =C2=A0 if (offset) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 *offset =3D off;
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 return memory_region_get_fd(mr);
> +}
> +
> +static bool proxy_mrs_can_merge(uint64_t host, uint64_t prev_host, si= ze_t size)
> +{
>
> This seems similar to vhost_user_can_merge().
>
> +=C2=A0 =C2=A0 bool merge;
> +=C2=A0 =C2=A0 int fd1, fd2;
> +
> +=C2=A0 =C2=A0 fd1 =3D get_fd_from_hostaddr(host, NULL);
> +
> +=C2=A0 =C2=A0 fd2 =3D get_fd_from_hostaddr(prev_host, NULL);
> +
> +=C2=A0 =C2=A0 merge =3D (fd1 =3D=3D fd2);
>
> This could be written in a simpler manner, ex:
>
> if (get_fd_from_hostaddr(host, NULL) !=3D get_fd_from_hostaddr(prev_ho= st, NULL))
>=C2=A0 =C2=A0return false
>
> +
> +=C2=A0 =C2=A0 merge &=3D ((prev_host + size) =3D=3D host);
>
> That check could be done early on before doing the more expensive memo= ry_region_from_host() calls
>
> +
> +=C2=A0 =C2=A0 return merge;
> +}
> +
> +static bool try_merge(RemoteMemSync *sync, MemoryRegionSection *secti= on)
> +{
> +=C2=A0 =C2=A0 uint64_t mrs_size, mrs_gpa, mrs_page;
> +=C2=A0 =C2=A0 MemoryRegionSection *prev_sec;
> +=C2=A0 =C2=A0 bool merged =3D false;
> +=C2=A0 =C2=A0 uintptr_t mrs_host;
> +=C2=A0 =C2=A0 RAMBlock *mrs_rb;
> +
> +=C2=A0 =C2=A0 if (!sync->n_mr_sections) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return false;
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 mrs_rb =3D section->mr->ram_block;
> +=C2=A0 =C2=A0 mrs_page =3D (uint64_t)qemu_ram_pagesize(mrs_rb);
> +=C2=A0 =C2=A0 mrs_size =3D int128_get64(section->size);
> +=C2=A0 =C2=A0 mrs_gpa =3D section->offset_within_address_space; > +=C2=A0 =C2=A0 mrs_host =3D (uintptr_t)memory_region_get_ram_ptr(secti= on->mr) +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0section->of= fset_within_region;
> +
> +=C2=A0 =C2=A0 if (get_fd_from_hostaddr(mrs_host, NULL) < 0) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return true;
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 mrs_host =3D mrs_host & ~(mrs_page - 1);
> +=C2=A0 =C2=A0 mrs_gpa =3D mrs_gpa & ~(mrs_page - 1);
> +=C2=A0 =C2=A0 mrs_size =3D ROUND_UP(mrs_size, mrs_page);
> +
> +=C2=A0 =C2=A0 prev_sec =3D sync->mr_sections + (sync->n_mr_sect= ions - 1);
> +=C2=A0 =C2=A0 uint64_t prev_gpa_start =3D prev_sec->offset_within_= address_space;
> +=C2=A0 =C2=A0 uint64_t prev_size =3D int128_get64(prev_sec->size);=
> +=C2=A0 =C2=A0 uint64_t prev_gpa_end=C2=A0 =C2=A0=3D range_get_last(pr= ev_gpa_start, prev_size);
> +=C2=A0 =C2=A0 uint64_t prev_host_start =3D
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (uintptr_t)memory_region_get_ram_ptr(prev= _sec->mr) +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 prev_sec->offset_within_region;
> +=C2=A0 =C2=A0 uint64_t prev_host_end =3D range_get_last(prev_host_sta= rt, prev_size);
> +
> +=C2=A0 =C2=A0 if (mrs_gpa <=3D (prev_gpa_end + 1)) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 g_assert(mrs_gpa > prev_gpa_start); > +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((section->mr =3D=3D prev_sec->m= r) &&
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 proxy_mrs_can_merge(mrs_hos= t, prev_host_start,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (mrs_gpa - prev_gpa_start))) { > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 uint64_t max_end =3D MAX(pr= ev_host_end, mrs_host + mrs_size);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 merged =3D true;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 prev_sec->offset_within_= address_space =3D
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MIN(prev_gpa_= start, mrs_gpa);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 prev_sec->offset_within_= region =3D
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 MIN(prev_host= _start, mrs_host) -
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (uintptr_t)me= mory_region_get_ram_ptr(prev_sec->mr);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 prev_sec->size =3D int12= 8_make64(max_end - MIN(prev_host_start,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0mrs_host));
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 return merged;
> +}
> +
> +static void proxy_ml_region_addnop(MemoryListener *listener,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0MemoryRegionSection= *section)
> +{
> +=C2=A0 =C2=A0 RemoteMemSync *sync =3D container_of(listener, RemoteMe= mSync, listener);
> +
> +=C2=A0 =C2=A0 if (!(memory_region_is_ram(section->mr) && > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 !memory_region_is_rom(section->= mr))) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
>
> A bit clearer in vhost.c:
> if (memory_region_is_ram(mr) && !memory_region_is_rom(mr)) { >=C2=A0
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 if (try_merge(sync, section)) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 ++sync->n_mr_sections;
> +=C2=A0 =C2=A0 sync->mr_sections =3D g_renew(MemoryRegionSection, s= ync->mr_sections,
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sync->n_mr_sections);
> +=C2=A0 =C2=A0 sync->mr_sections[sync->n_mr_sections - 1] =3D *s= ection;
> +=C2=A0 =C2=A0 sync->mr_sections[sync->n_mr_sections - 1].fv =3D= NULL;
> +=C2=A0 =C2=A0 memory_region_ref(section->mr);
> +}
> +
> +static void proxy_ml_commit(MemoryListener *listener)
> +{
> +=C2=A0 =C2=A0 RemoteMemSync *sync =3D container_of(listener, RemoteMe= mSync, listener);
> +=C2=A0 =C2=A0 MPQemuMsg msg;
> +=C2=A0 =C2=A0 MemoryRegionSection *section;
> +=C2=A0 =C2=A0 ram_addr_t offset;
> +=C2=A0 =C2=A0 uintptr_t host_addr;
> +=C2=A0 =C2=A0 int region;
> +=C2=A0 =C2=A0 Error *local_err =3D NULL;
> +
> +=C2=A0 =C2=A0 memset(&msg, 0, sizeof(MPQemuMsg));
> +
> +=C2=A0 =C2=A0 msg.cmd =3D SYNC_SYSMEM;
> +=C2=A0 =C2=A0 msg.num_fds =3D sync->n_mr_sections;
> +=C2=A0 =C2=A0 msg.size =3D sizeof(SyncSysmemMsg);
> +=C2=A0 =C2=A0 if (msg.num_fds > REMOTE_MAX_FDS) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 error_report("Number of fds is more = than %d", REMOTE_MAX_FDS);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
> +=C2=A0 =C2=A0 }
> +
> +=C2=A0 =C2=A0 for (region =3D 0; region < sync->n_mr_sections; = region++) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 section =3D &sync->mr_sections[reg= ion];
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 msg.data.sync_sysmem.gpas[region] =3D
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 section->offset_within_a= ddress_space;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 msg.data.sync_sysmem.sizes[region] =3D in= t128_get64(section->size);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 host_addr =3D (uintptr_t)memory_region_ge= t_ram_ptr(section->mr) +
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= section->offset_within_region;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 msg.fds[region] =3D get_fd_from_hostaddr(= host_addr, &offset);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 msg.data.sync_sysmem.offsets[region] =3D = offset;
> +=C2=A0 =C2=A0 }
> +=C2=A0 =C2=A0 mpqemu_msg_send(&msg, sync->ioc, &local_err)= ;
> +=C2=A0 =C2=A0 if (local_err) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 error_report("Error in sending comma= nd %d", msg.cmd);
> +=C2=A0 =C2=A0 }
> +}
>
> That whole complex code above duplicates much of the logic in vhost.c.= Can we try to factorize it instead?

Hi Marc-Andre,

Thank you for sharing your feedback!

Would it be alright if we addressed this item alone in a separate patch in = the future? Since
this refactoring affects vhost code, we=E2=80=99re wondering it would be be= tter to address it in a
future patch to help with any regression analysis in the future.

That's fine with me, but please leave a TODO = note in the code then.

thanks

=

Thank you!
=E2=80=94
Jag

>
> +
> +void deconfigure_memory_sync(RemoteMemSync *sync)
> +{
> +=C2=A0 =C2=A0 memory_listener_unregister(&sync->listener);
> +
> +=C2=A0 =C2=A0 proxy_ml_begin(&sync->listener);
> +}
> +
> +void configure_memory_sync(RemoteMemSync *sync, QIOChannel *ioc)
> +{
> +=C2=A0 =C2=A0 sync->n_mr_sections =3D 0;
> +=C2=A0 =C2=A0 sync->mr_sections =3D NULL;
> +
> +=C2=A0 =C2=A0 sync->ioc =3D ioc;
> +
> +=C2=A0 =C2=A0 sync->listener.begin =3D proxy_ml_begin;
> +=C2=A0 =C2=A0 sync->listener.commit =3D proxy_ml_commit;
> +=C2=A0 =C2=A0 sync->listener.region_add =3D proxy_ml_region_addnop= ;
> +=C2=A0 =C2=A0 sync->listener.region_nop =3D proxy_ml_region_addnop= ;
> +=C2=A0 =C2=A0 sync->listener.priority =3D 10;
> +
> +=C2=A0 =C2=A0 memory_listener_register(&sync->listener, &a= ddress_space_memory);
> +}
> diff --git a/hw/remote/message.c b/hw/remote/message.c
> index 0f3e38a..454fd2d 100644
> --- a/hw/remote/message.c
> +++ b/hw/remote/message.c
> @@ -17,6 +17,7 @@
>=C2=A0 #include "sysemu/runstate.h"
>=C2=A0 #include "hw/pci/pci.h"
>=C2=A0 #include "exec/memattrs.h"
> +#include "hw/remote/memory.h"
>
>=C2=A0 static void process_config_write(QIOChannel *ioc, PCIDevice *dev= ,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0MPQemuMsg *msg);
> @@ -64,6 +65,10 @@ void coroutine_fn mpqemu_remote_msg_loop_co(void *d= ata)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 case BAR_READ:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 process_bar_read(com-&= gt;ioc, &msg, &local_err);
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 case SYNC_SYSMEM:
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 remote_sysmem_reconfig(&= ;msg, &local_err);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;
> +
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 default:
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 error_setg(&local_= err,
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0"Unknown command (%d) received for device %s (pid= =3D%d)",
> diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c
> index 039347d..0f2d1aa 100644
> --- a/hw/remote/proxy.c
> +++ b/hw/remote/proxy.c
> @@ -18,6 +18,8 @@
>=C2=A0 #include "migration/blocker.h"
>=C2=A0 #include "hw/remote/mpqemu-link.h"
>=C2=A0 #include "qemu/error-report.h"
> +#include "hw/remote/memory-sync.h"
> +#include "qom/object.h"
>
>=C2=A0 static void proxy_set_socket(PCIProxyDev *pdev, int fd, Error **= errp)
>=C2=A0 {
> @@ -58,6 +60,8 @@ static void pci_proxy_dev_realize(PCIDevice *device,= Error **errp)
>
>=C2=A0 =C2=A0 =C2=A0 qemu_mutex_init(&dev->io_mutex);
>=C2=A0 =C2=A0 =C2=A0 qio_channel_set_blocking(dev->ioc, true, NULL);=
> +
> +=C2=A0 =C2=A0 configure_memory_sync(&dev->sync, dev->ioc);<= br> >=C2=A0 }
>
>=C2=A0 static void pci_proxy_dev_exit(PCIDevice *pdev)
> @@ -69,6 +73,8 @@ static void pci_proxy_dev_exit(PCIDevice *pdev)
>=C2=A0 =C2=A0 =C2=A0 migrate_del_blocker(dev->migration_blocker); >
>=C2=A0 =C2=A0 =C2=A0 error_free(dev->migration_blocker);
> +
> +=C2=A0 =C2=A0 deconfigure_memory_sync(&dev->sync);
>=C2=A0 }
>
>=C2=A0 static int config_op_send(PCIProxyDev *pdev, uint32_t addr, uint= 32_t *val,
> diff --git a/MAINTAINERS b/MAINTAINERS
> index ebd1d1d..5d78b78 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3150,6 +3150,8 @@ F: include/hw/remote/memory.h
>=C2=A0 F: hw/remote/memory.c
>=C2=A0 F: hw/remote/proxy.c
>=C2=A0 F: include/hw/remote/proxy.h
> +F: hw/remote/memory-sync.c
> +F: include/hw/remote/memory-sync.h
>
>=C2=A0 Build and test automation
>=C2=A0 -------------------------
> diff --git a/hw/remote/meson.build b/hw/remote/meson.build
> index 569cd20..7d434a5 100644
> --- a/hw/remote/meson.build
> +++ b/hw/remote/meson.build
> @@ -7,5 +7,6 @@ remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_= true: files('remote-obj.c'))
>=C2=A0 remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: file= s('proxy.c'))
>
>=C2=A0 specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: fi= les('memory.c'))
> +specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files(&= #39;memory-sync.c'))
>
>=C2=A0 softmmu_ss.add_all(when: 'CONFIG_MULTIPROCESS', if_true:= remote_ss)
> --
> 1.8.3.1
>
>
>
> --
> Marc-Andr=C3=A9 Lureau



--
Marc-Andr=C3=A9 Lureau
--00000000000027715805b60ebf31--