From: David Hildenbrand <david@redhat.com>
To: Elena Ufimtseva <elena.ufimtseva@oracle.com>, qemu-devel@nongnu.org
Cc: eduardo@habkost.net, john.g.johnson@oracle.com,
jag.raman@oracle.com, john.levon@nutanix.com, philmd@redhat.com,
cohuck@redhat.com, armbru@redhat.com, peterx@redhat.com,
mst@redhat.com, stefanha@redhat.com, pbonzini@redhat.com,
berrange@redhat.com, eblake@redhat.com
Subject: Re: [RFC 1/8] ioregionfd: introduce a syscall and memory API
Date: Wed, 16 Feb 2022 13:19:59 +0100 [thread overview]
Message-ID: <5cd206e3-f7f6-1fdb-10f9-26a7c12ec9b6@redhat.com> (raw)
In-Reply-To: <6001ed71ebe40c88e9d903bf0983884f522b2dea.1644302411.git.elena.ufimtseva@oracle.com>
Looks straight forward to me.
[...]
>
> +int kvm_set_ioregionfd(struct kvm_ioregion *ioregionfd)
> +{
> + KVMState *s = kvm_state;
> + int ret = -1;
> +
> + ret = kvm_vm_ioctl(s, KVM_SET_IOREGION, ioregionfd);
> + if (ret < 0) {
> + error_report("Failed SET_IOREGION syscall ret is %d", ret);
Maybe print the textual representation via strerror(-ret).
> + }
> + return ret;
> +}
> +
> static int do_kvm_destroy_vcpu(CPUState *cpu)
> {
> KVMState *s = kvm_state;
> @@ -1635,6 +1648,104 @@ static void kvm_io_ioeventfd_del(MemoryListener *listener,
> }
> }
>
> +static void kvm_mem_ioregionfd_add(MemoryListener *listener,
> + MemoryRegionSection *section,
> + uint64_t data,
> + int fd)
> +{
> +
> + struct kvm_ioregion ioregionfd;
> + int r = -1;
> +
> + ioregionfd.guest_paddr = section->offset_within_address_space;
> + ioregionfd.memory_size = int128_get64(section->size);
> + ioregionfd.user_data = data;
> + ioregionfd.read_fd = fd;
> + ioregionfd.write_fd = fd;
> + ioregionfd.flags = 0;
> + memset(&ioregionfd.pad, 0, sizeof(ioregionfd.pad));
> +
> + r = kvm_set_ioregionfd(&ioregionfd);
> + if (r < 0) {
> + fprintf(stderr, "%s: error adding ioregionfd: %s (%d)\n,",
> + __func__, strerror(-r), -r);
Oh, you're actually printing the error again? Why error_report() above
and here fprintf?
[...]
> void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
> AddressSpace *as, int as_id, const char *name)
> {
> @@ -1679,6 +1790,12 @@ static MemoryListener kvm_io_listener = {
> .priority = 10,
> };
>
> +static MemoryListener kvm_ioregion_listener = {
> + .ioregionfd_add = kvm_io_ioregionfd_add,
> + .ioregionfd_del = kvm_io_ioregionfd_del,
> + .priority = 10,
> +};
> +
> int kvm_set_irq(KVMState *s, int irq, int level)
> {
> struct kvm_irq_level event;
> @@ -2564,6 +2681,9 @@ static int kvm_init(MachineState *ms)
> kvm_ioeventfd_any_length_allowed =
> (kvm_check_extension(s, KVM_CAP_IOEVENTFD_ANY_LENGTH) > 0);
>
> + kvm_ioregionfds_allowed =
> + (kvm_check_extension(s, KVM_CAP_IOREGIONFD) > 0);
> +
> kvm_state = s;
>
> ret = kvm_arch_init(ms, s);
> @@ -2585,6 +2705,12 @@ static int kvm_init(MachineState *ms)
> s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add;
> s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del;
> }
> +
> + if (kvm_ioregionfds_allowed) {
> + s->memory_listener.listener.ioregionfd_add = kvm_mem_ioregionfd_add;
> + s->memory_listener.listener.ioregionfd_del = kvm_mem_ioregionfd_del;
> + }
> +
> s->memory_listener.listener.coalesced_io_add = kvm_coalesce_mmio_region;
> s->memory_listener.listener.coalesced_io_del = kvm_uncoalesce_mmio_region;
>
> @@ -2594,6 +2720,12 @@ static int kvm_init(MachineState *ms)
> memory_listener_register(&kvm_io_listener,
> &address_space_io);
> }
> +
> + if (kvm_ioregionfds_allowed) {
> + memory_listener_register(&kvm_ioregion_listener,
> + &address_space_io);
> + }
> +
> memory_listener_register(&kvm_coalesced_pio_listener,
> &address_space_io);
>
Why are we using a single memory listener for address_space_memory but
individual listeners for address_space_io?
IOW, wey don't we have &s->io_listener ?
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2022-02-16 12:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 7:22 [RFC 0/8] ioregionfd introduction Elena Ufimtseva
2022-02-08 7:22 ` [RFC 1/8] ioregionfd: introduce a syscall and memory API Elena Ufimtseva
2022-02-16 12:19 ` David Hildenbrand [this message]
2022-02-08 7:22 ` [RFC 2/8] multiprocess: place RemoteObject definition in a header file Elena Ufimtseva
2022-02-08 7:22 ` [RFC 3/8] ioregionfd: introduce memory API functions Elena Ufimtseva
2022-02-14 14:32 ` Stefan Hajnoczi
2022-02-08 7:22 ` [RFC 4/8] ioregionfd: Introduce IORegionDFObject type Elena Ufimtseva
2022-02-11 13:46 ` Markus Armbruster
2022-02-15 18:19 ` Elena
2022-02-14 14:37 ` Stefan Hajnoczi
2022-02-15 18:18 ` Elena
2022-02-16 11:08 ` Stefan Hajnoczi
2022-02-08 7:22 ` [RFC 5/8] multiprocess: prepare ioregionfds for remote device Elena Ufimtseva
2022-02-08 7:22 ` [RFC 6/8] multiprocess: add MPQEMU_CMD_BAR_INFO Elena Ufimtseva
2022-02-08 7:22 ` [RFC 7/8] multiprocess: add ioregionfd memory region in proxy Elena Ufimtseva
2022-02-08 7:22 ` [RFC 8/8] multiprocess: handle ioregionfd commands Elena Ufimtseva
2022-02-09 10:33 ` [RFC 0/8] ioregionfd introduction Stefan Hajnoczi
2022-02-14 14:52 ` Stefan Hajnoczi
2022-02-15 18:16 ` Elena
2022-02-16 11:20 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5cd206e3-f7f6-1fdb-10f9-26a7c12ec9b6@redhat.com \
--to=david@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=cohuck@redhat.com \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=elena.ufimtseva@oracle.com \
--cc=jag.raman@oracle.com \
--cc=john.g.johnson@oracle.com \
--cc=john.levon@nutanix.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).