diff --git a/options/options.c b/options/options.c index 0038221..003dd28 100644 --- a/options/options.c +++ b/options/options.c @@ -78,6 +78,7 @@ option_a (const char *arg, const char *format, int blocksize, /* Remote storage. */ drv->type = drv_uri; drv->uri.path = uri.path; + drv->uri.query = uri.query; drv->uri.protocol = uri.protocol; drv->uri.server = uri.server; drv->uri.username = uri.username; @@ -179,6 +180,11 @@ add_drives_handle (guestfs_h *g, struct drv *drv, size_t drive_index) ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_SECRET_BITMASK; ad_optargs.secret = drv->uri.password; } + if (drv->uri.query) { + ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_QUERY_BITMASK; + ad_optargs.query = drv->uri.query; + } + #ifdef GUESTFS_ADD_DRIVE_OPTS_BLOCKSIZE_BITMASK if (drv->uri.blocksize) { ad_optargs.bitmask |= GUESTFS_ADD_DRIVE_OPTS_BLOCKSIZE_BITMASK; diff --git a/options/options.h b/options/options.h index 26ec451..eda580f 100644 --- a/options/options.h +++ b/options/options.h @@ -68,6 +68,7 @@ struct drv { } a; struct { char *path; /* disk path */ + char *query; /* query string */ char *protocol; /* protocol (eg. "nbd") */ char **server; /* server(s) - can be NULL */ char *username; /* username - can be NULL */ diff --git a/options/uri.c b/options/uri.c index 9180d6a..00be626 100644 --- a/options/uri.c +++ b/options/uri.c @@ -41,7 +41,7 @@ #include "uri.h" static int is_uri (const char *arg); -static int parse (const char *arg, char **path_ret, char **protocol_ret, char ***server_ret, char **username_ret, char **password_ret); +static int parse (const char *arg, char **path_ret, char **query_ret, char **protocol_ret, char ***server_ret, char **username_ret, char **password_ret); static char *query_get (xmlURIPtr uri, const char *search_name); static int make_server (xmlURIPtr uri, const char *socket, char ***ret); @@ -49,6 +49,7 @@ int parse_uri (const char *arg, struct uri *uri_ret) { char *path = NULL; + char *query = NULL; char *protocol = NULL; char **server = NULL; char *username = NULL; @@ -56,7 +57,7 @@ parse_uri (const char *arg, struct uri *uri_ret) /* Does it look like a URI? */ if (is_uri (arg)) { - if (parse (arg, &path, &protocol, &server, &username, &password) == -1) + if (parse (arg, &path, &query, &protocol, &server, &username, &password) == -1) return -1; } else { @@ -75,6 +76,7 @@ parse_uri (const char *arg, struct uri *uri_ret) } uri_ret->path = path; + uri_ret->query = query; uri_ret->protocol = protocol; uri_ret->server = server; uri_ret->username = username; @@ -107,7 +109,7 @@ is_uri (const char *arg) } static int -parse (const char *arg, char **path_ret, char **protocol_ret, +parse (const char *arg, char **path_ret, char **query_ret, char **protocol_ret, char ***server_ret, char **username_ret, char **password_ret) { CLEANUP_XMLFREEURI xmlURIPtr uri = NULL; @@ -212,6 +214,17 @@ parse (const char *arg, char **path_ret, char **protocol_ret, return -1; } + *query_ret = strdup(uri->query_raw ? uri->query_raw : ""); + if (*query_ret == NULL) { + perror ("strdup: query"); + free (*protocol_ret); + guestfs_int_free_string_list (*server_ret); + free (*username_ret); + free (*password_ret); + free (*path_ret); + return -1; + } + return 0; } diff --git a/options/uri.h b/options/uri.h index 9202a70..d44bac2 100644 --- a/options/uri.h +++ b/options/uri.h @@ -23,6 +23,7 @@ struct uri { char *path; /* disk path */ + char *query; /* query string */ char *protocol; /* protocol (eg. "file", "nbd") */ char **server; /* server(s) - can be NULL */ char *username; /* username - can be NULL */