diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-07-24 11:12:46 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-07-24 13:01:08 +0100 |
commit | 507aa9ac35e2d7d200ee48f0d3d9dfa0f1644ef1 (patch) | |
tree | 0165cf1259014129513632acb6c842feb0d0b02b /src/launch-libvirt.c | |
parent | d8b2c1afee4e23ca864727bebc53a04c490715bc (diff) | |
download | libguestfs-507aa9ac35e2d7d200ee48f0d3d9dfa0f1644ef1.tar.gz libguestfs-507aa9ac35e2d7d200ee48f0d3d9dfa0f1644ef1.tar.xz libguestfs-507aa9ac35e2d7d200ee48f0d3d9dfa0f1644ef1.zip |
launch: libvirt: Add is_blk utility.
This is just code motion.
Diffstat (limited to 'src/launch-libvirt.c')
-rw-r--r-- | src/launch-libvirt.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c index a990a332..80754b3c 100644 --- a/src/launch-libvirt.c +++ b/src/launch-libvirt.c @@ -79,6 +79,7 @@ xmlBufferDetach (xmlBufferPtr buf) static xmlChar *construct_libvirt_xml (guestfs_h *g, const char *capabilities_xml, const char *kernel, const char *initrd, const char *appliance, const char *guestfsd_sock, const char *console_sock); static char *autodetect_format (guestfs_h *g, const char *path); static void libvirt_error (guestfs_h *g, const char *fs, ...); +static int is_blk (const char *path); static int launch_libvirt (guestfs_h *g, const char *libvirt_uri) @@ -762,7 +763,6 @@ construct_libvirt_xml_disk (guestfs_h *g, xmlTextWriterPtr xo, char scsi_target[64]; char *path = NULL; char *format = NULL; - struct stat statbuf; int is_host_device; guestfs___drive_name (drv_index, &drive_name[2]); @@ -776,11 +776,7 @@ construct_libvirt_xml_disk (guestfs_h *g, xmlTextWriterPtr xo, * <disk type=file device=disk> * <source file=[path]> */ - if (stat (drv->path, &statbuf) == -1) { - perrorf (g, "stat: %s", drv->path); - goto err; - } - is_host_device = S_ISBLK (statbuf.st_mode); + is_host_device = is_blk (drv->path); /* Path must be absolute for libvirt. */ path = realpath (drv->path, NULL); @@ -1150,6 +1146,16 @@ autodetect_format (guestfs_h *g, const char *path) } static int +is_blk (const char *path) +{ + struct stat statbuf; + + if (stat (path, &statbuf) == -1) + return 0; + return S_ISBLK (statbuf.st_mode); +} + +static int shutdown_libvirt (guestfs_h *g) { virConnectPtr conn = g->virt.connv; |