Score:0

kmv/qemu vm guests and host are connected through shared memory to collect and cache data beteween them

ge flag

0

The configuration: host: Ubuntu:20.04 OS, guest: Ubuntu20.04 OS. The two files use the 9p file system for interworking.

The current progress is as follows: the mmap function in C language is used to map the memory of the same file through the 9p file system. At present, host can write to the memory of the file, but guest cannot read the change in real time.

guest: read.c

enter image description here

host:write.c

enter image description here

Score:0
sl flag

punching holes between guest and host isn't a thing that should be done too easily as it is a perfect vector of attack/escape. But I know, sometimes the use-case outweights the risks. But then I'd not try to use 9pfs and instead recommend to have a look at ivshmem.

That isn't great and most used either, but at least meant to more or less do what you ask for.

People have been trying to use the example applications ivshmem-server/client for production (which shouldn't be encouraged), so they have been removed in qemu 5.2 and later in Debian and Ubuntu. But if you want to go via that, you can still build and use those example tools yourself (or Use Ubuntu Focal for your experiments which still has them).

If instead you want to directly code against the interface you might want to start at this example ivshmem tutorial.

This even works nicely and more expressive through libvirt XMLs. This:

  <shmem name='my_shmem0' role='peer'>
    <model type='ivshmem-plain'/>
    <size unit='M'>4</size>
  </shmem>

Gave me automatically

-object '{"qom-type":"memory-backend-file","id":"shmmem-shmem0","mem-path":"/dev/shm/my_shmem0","size":4194304,"share":true}' \
-device '{"driver":"ivshmem-plain","id":"shmem0","memdev":"shmmem-shmem0","master":"off","bus":"pci.9","addr":"0x1"}' \
$ lspci
...
08:01.0 RAM memory: Red Hat, Inc. Inter-VM shared memory (rev 01)

You need to get permissions. For example the program/user writing in the host could become part of the kvm group (again, not recommended to grant too easily as it grants permissions not everyone should have).

But then you can, as the tutorial outlines (well, modify size and pci id accordingly), access that from guest and host.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.