On Thu, Jun 10, 2010 at 05:03:10AM -0600, Eric Blake wrote: > On 06/10/2010 04:16 AM, Daniel P. Berrange wrote: > >> > >> - if (virAsprintf(&dest, "exec:%s | dd of=%s bs=%llu seek=%llu", > >> - argstr, safe_target, > >> - QEMU_MONITOR_MIGRATE_TO_FILE_BS, > >> - offset / QEMU_MONITOR_MIGRATE_TO_FILE_BS) < 0) { > >> + /* Two dd processes, sharing the same stdout, are necessary to > >> + * allow starting at an alignment of 512, but without wasting > >> + * padding to get to the larger alignment useful for speed. */ > >> + if (virAsprintf(&dest, "exec:%s | { dd bs=%llu seek=%llu if=/dev/null && " > >> + "dd bs=%llu; } >%s", > > > > Does this work with block devices as the target ? We previously > > switched from cat>> to dd, because it didn't work correctly with block > > devs. > > Yes - the problem with >>dev was that it appended (which doesn't make > sense for a block device); while >dev opens a seekable fd. One > difference between 'dd >file' and 'dd of=file' is which process opens > the device; but to share the fd between two dd invocations, we have to > open the file in the shell rather than with of=file. The other > difference is that >file truncates; for block devices, truncation is a > no-op, but for regular files, this wipes out any pre-existing contents > (such as the header we are skipping over) - is that an issue? If so, > then we should use <>file instead of >file, to open a read-write fd > without forcing truncation (even if we only use the fd for writing). Yes, we need to avoid truncation - the seek is there to skip over the metadata header, so we can't truncate that Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list