qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Loadable block drivers?
@ 2018-04-03  2:59 Lindsay Mathieson
  2018-04-03  3:11 ` Fam Zheng
  0 siblings, 1 reply; 8+ messages in thread
From: Lindsay Mathieson @ 2018-04-03  2:59 UTC (permalink / raw)
  To: qemu-devel

Hi all, was looking at developing a block driver for qemu - have examined
the drivers at:

  https://github.com/qemu/qemu/tree/master/block

And it seems straightforward enough.

One thing that is unclear - all the drivers appear to be compiled directly
into qemu. Is there no way to load them dynamically as .so modules?

Thanks,

-- 
Lindsay

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] Loadable block drivers?
  2018-04-03  2:59 [Qemu-devel] Loadable block drivers? Lindsay Mathieson
@ 2018-04-03  3:11 ` Fam Zheng
  2018-04-03  3:17   ` Lindsay Mathieson
  0 siblings, 1 reply; 8+ messages in thread
From: Fam Zheng @ 2018-04-03  3:11 UTC (permalink / raw)
  To: Lindsay Mathieson; +Cc: qemu-devel

On Tue, 04/03 12:59, Lindsay Mathieson wrote:
> Hi all, was looking at developing a block driver for qemu - have examined
> the drivers at:
> 
>   https://github.com/qemu/qemu/tree/master/block
> 
> And it seems straightforward enough.
> 
> One thing that is unclear - all the drivers appear to be compiled directly
> into qemu. Is there no way to load them dynamically as .so modules?

'./configure --enable-modules' will enable building block drivers as .so
objects, and they are loaded dynamically. These are in-tree .so modules;
out-of-tree modules like in Linux kernel are intentionally forbidden.

Fam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] Loadable block drivers?
  2018-04-03  3:11 ` Fam Zheng
@ 2018-04-03  3:17   ` Lindsay Mathieson
  2018-04-03  3:30     ` Fam Zheng
  0 siblings, 1 reply; 8+ messages in thread
From: Lindsay Mathieson @ 2018-04-03  3:17 UTC (permalink / raw)
  To: Fam Zheng; +Cc: qemu-devel

On 3 April 2018 at 13:11, Fam Zheng <famz@redhat.com> wrote:

> On Tue, 04/03 12:59, Lindsay Mathieson wrote:
> > Hi all, was looking at developing a block driver for qemu - have examined
> > the drivers at:
> >
> >   https://github.com/qemu/qemu/tree/master/block
> >
> > And it seems straightforward enough.
> >
> > One thing that is unclear - all the drivers appear to be compiled
> directly
> > into qemu. Is there no way to load them dynamically as .so modules?
>
> './configure --enable-modules' will enable building block drivers as .so
> objects, and they are loaded dynamically. These are in-tree .so modules;
> out-of-tree modules like in Linux kernel are intentionally forbidden.
>
> Fam
>



Rats, I take it that means I can't develop a testing block module and load
it with an pre-existing qemu install.

thanks.

-- 
Lindsay

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] Loadable block drivers?
  2018-04-03  3:17   ` Lindsay Mathieson
@ 2018-04-03  3:30     ` Fam Zheng
  2018-04-04 13:41       ` Stefan Hajnoczi
  0 siblings, 1 reply; 8+ messages in thread
From: Fam Zheng @ 2018-04-03  3:30 UTC (permalink / raw)
  To: Lindsay Mathieson; +Cc: qemu-devel

On Tue, 04/03 13:17, Lindsay Mathieson wrote:
> On 3 April 2018 at 13:11, Fam Zheng <famz@redhat.com> wrote:
> 
> > On Tue, 04/03 12:59, Lindsay Mathieson wrote:
> > > Hi all, was looking at developing a block driver for qemu - have examined
> > > the drivers at:
> > >
> > >   https://github.com/qemu/qemu/tree/master/block
> > >
> > > And it seems straightforward enough.
> > >
> > > One thing that is unclear - all the drivers appear to be compiled
> > directly
> > > into qemu. Is there no way to load them dynamically as .so modules?
> >
> > './configure --enable-modules' will enable building block drivers as .so
> > objects, and they are loaded dynamically. These are in-tree .so modules;
> > out-of-tree modules like in Linux kernel are intentionally forbidden.
> >
> > Fam
> >
> 
> 
> 
> Rats, I take it that means I can't develop a testing block module and load
> it with an pre-existing qemu install.

No, that's not possible.

Fam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] Loadable block drivers?
  2018-04-03  3:30     ` Fam Zheng
@ 2018-04-04 13:41       ` Stefan Hajnoczi
  2018-04-05  1:40         ` Lindsay Mathieson
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Hajnoczi @ 2018-04-04 13:41 UTC (permalink / raw)
  To: Lindsay Mathieson; +Cc: qemu-devel, Fam Zheng

[-- Attachment #1: Type: text/plain, Size: 1648 bytes --]

On Tue, Apr 03, 2018 at 11:30:33AM +0800, Fam Zheng wrote:
> On Tue, 04/03 13:17, Lindsay Mathieson wrote:
> > On 3 April 2018 at 13:11, Fam Zheng <famz@redhat.com> wrote:
> > 
> > > On Tue, 04/03 12:59, Lindsay Mathieson wrote:
> > > > Hi all, was looking at developing a block driver for qemu - have examined
> > > > the drivers at:
> > > >
> > > >   https://github.com/qemu/qemu/tree/master/block
> > > >
> > > > And it seems straightforward enough.
> > > >
> > > > One thing that is unclear - all the drivers appear to be compiled
> > > directly
> > > > into qemu. Is there no way to load them dynamically as .so modules?
> > >
> > > './configure --enable-modules' will enable building block drivers as .so
> > > objects, and they are loaded dynamically. These are in-tree .so modules;
> > > out-of-tree modules like in Linux kernel are intentionally forbidden.
> > >
> > > Fam
> > >
> > 
> > 
> > 
> > Rats, I take it that means I can't develop a testing block module and load
> > it with an pre-existing qemu install.
> 
> No, that's not possible.

Depending on what you are trying to do, you could use the blkdebug,
null-co, NBD, or iSCSI drivers to perform your testing.

blkdebug does fault injection (e.g. you can test what happens when
certain I/O requests fail).

null-co is a nop block driver useful for some types of performance
testing and it also supports introducing an artificial delays.

NBD and iSCSI can be used to forward I/O requests to an external server
where you can implement any behavior you want.

We can discuss it more if you can explain what you're trying to do.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] Loadable block drivers?
  2018-04-04 13:41       ` Stefan Hajnoczi
@ 2018-04-05  1:40         ` Lindsay Mathieson
  2018-04-08  9:27           ` Fam Zheng
  2018-04-09  6:19           ` Stefan Hajnoczi
  0 siblings, 2 replies; 8+ messages in thread
From: Lindsay Mathieson @ 2018-04-05  1:40 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel, Fam Zheng

On 4 April 2018 at 23:41, Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Tue, Apr 03, 2018 at 11:30:33AM +0800, Fam Zheng wrote:
> > On Tue, 04/03 13:17, Lindsay Mathieson wrote:
> > > On 3 April 2018 at 13:11, Fam Zheng <famz@redhat.com> wrote:
> > >
> > > > On Tue, 04/03 12:59, Lindsay Mathieson wrote:
> > > > > Hi all, was looking at developing a block driver for qemu - have
> examined
> > > > > the drivers at:
> > > > >
> > > > >   https://github.com/qemu/qemu/tree/master/block
> > > > >
> > > > > And it seems straightforward enough.
> > > > >
> > > > > One thing that is unclear - all the drivers appear to be compiled
> > > > directly
> > > > > into qemu. Is there no way to load them dynamically as .so modules?
> > > >
> > > > './configure --enable-modules' will enable building block drivers as
> .so
> > > > objects, and they are loaded dynamically. These are in-tree .so
> modules;
> > > > out-of-tree modules like in Linux kernel are intentionally forbidden.
> > > >
> > > > Fam
> > > >
> > >
> > >
> > >
> > > Rats, I take it that means I can't develop a testing block module and
> load
> > > it with an pre-existing qemu install.
> >
> > No, that's not possible.
>
> Depending on what you are trying to do, you could use the blkdebug,
> null-co, NBD, or iSCSI drivers to perform your testing.
>
> blkdebug does fault injection (e.g. you can test what happens when
> certain I/O requests fail).
>
> null-co is a nop block driver useful for some types of performance
> testing and it also supports introducing an artificial delays.
>
> NBD and iSCSI can be used to forward I/O requests to an external server
> where you can implement any behavior you want.
>
> We can discuss it more if you can explain what you're trying to do.
>
> Stefan
>



Thanks Stefan, looking to develop a lizardfs block driver. A process that
only involved building a module rather than the entire qemu tree would mike
life easier, especially if I could test it on a live system (proxmox
cluster). A custom qemu install is not an option for that.

-- 
Lindsay

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] Loadable block drivers?
  2018-04-05  1:40         ` Lindsay Mathieson
@ 2018-04-08  9:27           ` Fam Zheng
  2018-04-09  6:19           ` Stefan Hajnoczi
  1 sibling, 0 replies; 8+ messages in thread
From: Fam Zheng @ 2018-04-08  9:27 UTC (permalink / raw)
  To: Lindsay Mathieson; +Cc: Stefan Hajnoczi, qemu-devel

On Thu, 04/05 11:40, Lindsay Mathieson wrote:
> On 4 April 2018 at 23:41, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> 
> > On Tue, Apr 03, 2018 at 11:30:33AM +0800, Fam Zheng wrote:
> > > On Tue, 04/03 13:17, Lindsay Mathieson wrote:
> > > > On 3 April 2018 at 13:11, Fam Zheng <famz@redhat.com> wrote:
> > > >
> > > > > On Tue, 04/03 12:59, Lindsay Mathieson wrote:
> > > > > > Hi all, was looking at developing a block driver for qemu - have
> > examined
> > > > > > the drivers at:
> > > > > >
> > > > > >   https://github.com/qemu/qemu/tree/master/block
> > > > > >
> > > > > > And it seems straightforward enough.
> > > > > >
> > > > > > One thing that is unclear - all the drivers appear to be compiled
> > > > > directly
> > > > > > into qemu. Is there no way to load them dynamically as .so modules?
> > > > >
> > > > > './configure --enable-modules' will enable building block drivers as
> > .so
> > > > > objects, and they are loaded dynamically. These are in-tree .so
> > modules;
> > > > > out-of-tree modules like in Linux kernel are intentionally forbidden.
> > > > >
> > > > > Fam
> > > > >
> > > >
> > > >
> > > >
> > > > Rats, I take it that means I can't develop a testing block module and
> > load
> > > > it with an pre-existing qemu install.
> > >
> > > No, that's not possible.
> >
> > Depending on what you are trying to do, you could use the blkdebug,
> > null-co, NBD, or iSCSI drivers to perform your testing.
> >
> > blkdebug does fault injection (e.g. you can test what happens when
> > certain I/O requests fail).
> >
> > null-co is a nop block driver useful for some types of performance
> > testing and it also supports introducing an artificial delays.
> >
> > NBD and iSCSI can be used to forward I/O requests to an external server
> > where you can implement any behavior you want.
> >
> > We can discuss it more if you can explain what you're trying to do.
> >
> > Stefan
> >
> 
> 
> 
> Thanks Stefan, looking to develop a lizardfs block driver. A process that
> only involved building a module rather than the entire qemu tree would mike
> life easier, especially if I could test it on a live system (proxmox
> cluster). A custom qemu install is not an option for that.

I cannot think of a way to hot plugging a block driver to a running QEMU, but
perhaps you can live migrate the VM from the stock QEMU to a custom built one to
achieve similar.

Fam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] Loadable block drivers?
  2018-04-05  1:40         ` Lindsay Mathieson
  2018-04-08  9:27           ` Fam Zheng
@ 2018-04-09  6:19           ` Stefan Hajnoczi
  1 sibling, 0 replies; 8+ messages in thread
From: Stefan Hajnoczi @ 2018-04-09  6:19 UTC (permalink / raw)
  To: Lindsay Mathieson; +Cc: qemu-devel, Fam Zheng

[-- Attachment #1: Type: text/plain, Size: 1551 bytes --]

On Thu, Apr 05, 2018 at 11:40:31AM +1000, Lindsay Mathieson wrote:
> Thanks Stefan, looking to develop a lizardfs block driver. A process that
> only involved building a module rather than the entire qemu tree would mike
> life easier, especially if I could test it on a live system (proxmox
> cluster). A custom qemu install is not an option for that.

Since your final goal is to create a native LizardFS block driver, it is
necessary to build a full QEMU.

With libvirt you can edit the domain XML to point
<emulator>/usr/bin/qemu-kvm</emulator> at your custom binary for just
that VM.

In the worst case you can put a little shell script in place of the
system QEMU binary that checks the command-line arguments to detect your
test VM.  It can exec your custom QEMU binary for the test VM, and the
system QEMU binary for all other VMs:

  # mv /usr/bin/qemu-kvm /usr/bin/qemu-kvm.orig
  # cat >/usr/bin/qemu-kvm
  #!/bin/sh
  if echo "$*" | grep -q -- '-name testvm'; then
      exec /path/to/custom/qemu "$@"
  else
      exec /usr/bin/qemu-kvm.orig "$@"
  fi
  ^D
  # chmod 755 /usr/bin/qemu-kvm

I recommend using qemu.git/master and not an old source tree to avoid
extra work if you want to contribute your code or if you need to ask for
help (the first question will be "does it work on qemu.git/master?" :)).

QEMU does not have stable APIs or out-of-tree modules.  Development is
most convenient when done upstream as part of the community.  Anything
else requires you to maintain a fork and community support will be very
limited.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-09  6:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03  2:59 [Qemu-devel] Loadable block drivers? Lindsay Mathieson
2018-04-03  3:11 ` Fam Zheng
2018-04-03  3:17   ` Lindsay Mathieson
2018-04-03  3:30     ` Fam Zheng
2018-04-04 13:41       ` Stefan Hajnoczi
2018-04-05  1:40         ` Lindsay Mathieson
2018-04-08  9:27           ` Fam Zheng
2018-04-09  6:19           ` Stefan Hajnoczi

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).