<br><br><div class="gmail_quote"><div dir="ltr">בתאריך יום ה׳, 8 במרץ 2018, 14:29, מאת Richard W.M. Jones ‏<<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Mar 08, 2018 at 12:13:01PM +0000, Nir Soffer wrote:<br>
> On Wed, Mar 7, 2018 at 12:18 AM Richard W.M. Jones <<a href="mailto:rjones@redhat.com" target="_blank">rjones@redhat.com</a>><br>
> wrote:<br>
><br>
> > Previous versions:<br>
> >   v3: <a href="https://www.redhat.com/archives/libguestfs/2018-March/msg00000.html" rel="noreferrer" target="_blank">https://www.redhat.com/archives/libguestfs/2018-March/msg00000.html</a><br>
> >   v2:<br>
> > <a href="https://www.redhat.com/archives/libguestfs/2018-February/msg00177.html" rel="noreferrer" target="_blank">https://www.redhat.com/archives/libguestfs/2018-February/msg00177.html</a><br>
> >   v1:<br>
> > <a href="https://www.redhat.com/archives/libguestfs/2018-February/msg00139.html" rel="noreferrer" target="_blank">https://www.redhat.com/archives/libguestfs/2018-February/msg00139.html</a><br>
> ><br>
> > This completely rethinks the approach taken by the previous patches.<br>
> ><br>
> > Instead of trying to involve qemu's curl driver, this uses a small<br>
> > Python 3 nbdkit plugin to interface between qemu and the oVirt server.<br>
> ><br>
> > The data path is:<br>
> ><br>
> >   qemu-img convert  ------->   nbdkit   ------->   oVirt imageio<br>
> >                       nbd                 https<br>
> ><br>
><br>
> What is the advantage of this for raw files? Why not:<br>
><br>
>     v2v -> ovirt imageio?<br>
<br>
Not sure I understand what you mean?  virt-v2v always runs ‘qemu-img<br>
convert’ to do the copy (not conversion), so the question is how do we<br>
connect qemu-img to the oVirt server.  One way would be to extend qemu<br>
so it knows how to write on an https connection (which it does not do<br>
now) but that has a number of disadvantages, as well as being hard to<br>
implement.<br>
<br>
> And how qcow2 files will be handled?<br>
<br>
We'll add ‘-O qcow2’ to the qemu-img convert command line, and qemu<br>
will then write out a qcow2 file.  However it's not quite so<br>
straightforward (and in fact I didn't get it to work yet).  qemu will<br>
try to first read from the target (invoking pread calls in the nbdkit<br>
Python plugin which will try to read from oVirt over https).<br>
Unfortunately it fails here for a couple of reasons:<br>
<br>
(1) My pread method is broken.  I saw your suggested fixes to it (and<br>
pwrite) and will try those later.<br>
<br>
(2) In any case it won't work because the disk at this point is empty<br>
and full of zeroes, and it's looking for a qcow2 header.  To fix this<br>
we'll have to write a qcow2 header to the disk first (TBD).<br></blockquote></div><div><br></div><div>When you create a disk using qcow2 format ovirt creates a qcow2 empty image with the specified virtual size, so we should work.</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> when I tried nbdkit few month ago I could not make it handle qcow2<br>
> files. Maybe I had to write a plugin?<br>
<br>
NBD (the protocol) doesn't "know" about qcow2 files.  You can serve<br>
any file you want as a range of bytes, including qcow2, but that<br>
requires whatever is consuming those bytes to then do the qcow2<br>
en-/decoding.  (Which means effectively the client has to be qemu<br>
because nothing else can parse qcow2 reliably).  In the qemu-img<br>
convert case above this all works because qemu-img (ie. qemu) is the<br>
client, and it does the encoding of qcow2, and we're just shuffling a<br>
byte stream to oVirt imageio.<br>
<br>
> We considered using this flow when we download/upload images,<br>
> to support on-the-fly image conversion:<br>
><br>
>     raw file -> qemu-img convert -> nbdkit -> qcow2 stream -> imageio -><br>
> http client<br>
><br>
> And same for uploading, e.g. uploading qcow2 and writing raw image.<br>
><br>
> If this is possible using nbdkit plugin, can we ruse the same plugin in<br>
> different applications, or we must implement the plugin in each application?<br>
<br>
This should be possible (modulo fixing issues (1) & (2) above).  The<br>
plugin I have written is very specific to the virt-v2v task, but it<br>
could be evolved into something which would handle this case.<br>
<br>
nbdkit is designed around the idea that you can make small plugins in<br>
familiar scripting languages for specific tasks.<br>
<br>
I did think about having a generic "oVirt plugin" which we'd ship with<br>
upstream nbdkit, but making it generic enough to handle a useful range<br>
of cases seemed difficult.<br></blockquote></div><div><br></div><div>I agree, when we have a working plugin we will try to adapt it to our use case.</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> > There are two Python scripts included.  One is the nbdkit plugin.  The<br>
> > other creates the VM.  As with the previous patches, these scripts get<br>
> > embeded in virt-v2v at compile time, so effectively there is no API<br>
> > contract between virt-v2v & the Python code.<br>
> ><br>
> > With this patch series I am able to (mostly) successfully convert VMs<br>
> > from local disk to oVirt 4.2, with full end-to-end streaming.  There<br>
> > is some room for optimization -- in particular uploads are currently<br>
> > rather slow because we rely on qemu-img batching small requests into<br>
> > large ones which it doesn't do well, and instead the nbdkit plugin<br>
> > could batch small writes into larger ones.  Also I noticed (but only<br>
> > one time) that very long transfers would cause the oVirt ticket to<br>
> > expire, even though we were writing the whole time.<br>
> ><br>
><br>
> On the host, the ticket is extended regularly, based on the activity.<br>
><br>
> On the proxy we currently have 3600 seconds timeout, and the ticket<br>
> is never extended. I think we should have the same mechanism as<br>
> we do on the host.<br>
<br>
I have only seen this once and never again, so hopefully it was just a<br>
network blip causing a > 3600 second timeout.<br>
<br>
If it happens again I'll take a closer look.<br>
<br>
Thanks for the review, it does seem like pwrite is rather broken.<br>
Unfortunately my ovirt node hangs hard when I try to boot any guest<br>
(seems like a kernel or even hardware bug) so I have never been able<br>
to test that the transferred guest works :-(<br>
<br>
Rich.<br>
<br>
> Nir<br>
><br>
> There are still a few unresolved issues (see patch 3/3) so this is not<br>
> > quite ready to go upstream yet, but can still be reviewed.  Patches 1<br>
> > & 2 are the same as posted before.<br>
> ><br>
> > I did not yet test qcow2 uploads.  Those are "interestingly" different<br>
> > because qcow2 will require us to read from the remote oVirt server as<br>
> > well as just stream/write to it.  The pread method for that is written<br>
> > but has not been tested.<br>
> ><br>
> > Rich.<br>
> ><br>
> > _______________________________________________<br>
> > Libguestfs mailing list<br>
> > <a href="mailto:Libguestfs@redhat.com" target="_blank">Libguestfs@redhat.com</a><br>
> > <a href="https://www.redhat.com/mailman/listinfo/libguestfs" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/libguestfs</a><br>
> ><br>
<br>
--<br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones</a><br>
Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
virt-p2v converts physical machines to virtual machines.  Boot with a<br>
live CD or over the network (PXE) and turn machines into KVM guests.<br>
<a href="http://libguestfs.org/virt-v2v" rel="noreferrer" target="_blank">http://libguestfs.org/virt-v2v</a><br>
</blockquote></div>