Re: [Qemu-devel] Loadable block drivers?

2018-04-09 Thread Stefan Hajnoczi
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
/usr/bin/qemu-kvm 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


signature.asc
Description: PGP signature


Re: [Qemu-devel] Loadable block drivers?

2018-04-08 Thread Fam Zheng
On Thu, 04/05 11:40, Lindsay Mathieson wrote:
> On 4 April 2018 at 23:41, Stefan Hajnoczi  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  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



Re: [Qemu-devel] Loadable block drivers?

2018-04-04 Thread Lindsay Mathieson
On 4 April 2018 at 23:41, Stefan Hajnoczi  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  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


Re: [Qemu-devel] Loadable block drivers?

2018-04-04 Thread Stefan Hajnoczi
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  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


signature.asc
Description: PGP signature


Re: [Qemu-devel] Loadable block drivers?

2018-04-02 Thread Fam Zheng
On Tue, 04/03 13:17, Lindsay Mathieson wrote:
> On 3 April 2018 at 13:11, Fam Zheng  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



Re: [Qemu-devel] Loadable block drivers?

2018-04-02 Thread Lindsay Mathieson
On 3 April 2018 at 13:11, Fam Zheng  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


Re: [Qemu-devel] Loadable block drivers?

2018-04-02 Thread Fam Zheng
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



[Qemu-devel] Loadable block drivers?

2018-04-02 Thread Lindsay Mathieson
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