Beispiel #1
0
/**
 * Parse the first line of C<qemu_help> into the major and minor
 * version of qemu, but don't fail if parsing is not possible.
 */
static void
parse_qemu_version (guestfs_h *g, const char *qemu_help,
                    struct version *qemu_version)
{
  CLEANUP_FREE char *major_s = NULL, *minor_s = NULL;
  int major_i, minor_i;

  version_init_null (qemu_version);

  if (!match2 (g, qemu_help, re_major_minor, &major_s, &minor_s)) {
  parse_failed:
    debug (g, "%s: failed to parse qemu version string from the first line of the output of '%s -help'.  When reporting this bug please include the -help output.",
           __func__, g->hv);
    return;
  }

  major_i = guestfs_int_parse_unsigned_int (g, major_s);
  if (major_i == -1)
    goto parse_failed;

  minor_i = guestfs_int_parse_unsigned_int (g, minor_s);
  if (minor_i == -1)
    goto parse_failed;

  guestfs_int_version_from_values (qemu_version, major_i, minor_i, 0);

  debug (g, "qemu version %d.%d", major_i, minor_i);
}
Beispiel #2
0
/* This is called for whole block devices.  See if the device is an
 * ISO and we are able to read the ISO info from it.  In that case,
 * try using libosinfo to map from the volume ID and other strings
 * directly to the operating system type.
 */
int
guestfs_int_check_installer_iso (guestfs_h *g, struct inspect_fs *fs,
				 const char *device)
{
  CLEANUP_FREE_ISOINFO struct guestfs_isoinfo *isoinfo = NULL;
  const struct osinfo *osinfo;
  int r;

  guestfs_push_error_handler (g, NULL, NULL);
  isoinfo = guestfs_isoinfo_device (g, device);
  guestfs_pop_error_handler (g);
  if (!isoinfo)
    return 0;

  r = guestfs_int_osinfo_map (g, isoinfo, &osinfo);
  if (r == -1)                  /* Fatal error. */
    return -1;
  if (r == 0)                   /* Could not locate any matching ISO. */
    return 0;

  /* Otherwise we matched an ISO, so fill in the fs fields. */
  fs->mountable = safe_strdup (g, device);
  fs->role = OS_ROLE_ROOT;
  if (osinfo->is_installer)
    fs->format = OS_FORMAT_INSTALLER;
  fs->type = osinfo->type;
  fs->distro = osinfo->distro;
  fs->product_name =
    osinfo->product_name ? safe_strdup (g, osinfo->product_name) : NULL;
  guestfs_int_version_from_values (&fs->version, osinfo->major_version,
                                   osinfo->minor_version, 0);
  fs->arch = osinfo->arch ? safe_strdup (g, osinfo->arch) : NULL;
  fs->is_live_disk = osinfo->is_live_disk;

  guestfs_int_check_package_format (g, fs);
  guestfs_int_check_package_management (g, fs);

  return 1;
}