[libvirt] [libvirt-designer][PATCH 3/4] examples: Create an example of usage program
Christophe Fergeau
cfergeau at redhat.com
Mon Sep 10 09:12:44 UTC 2012
Hey,
I haven't looked at the patch in depth, just a few comments:
On Wed, Sep 05, 2012 at 11:27:46AM +0200, Michal Privoznik wrote:
> +
> + /* Standard (non-command) options. The leading + ensures that no
> + * argument reordering takes place, so that command options are
> + * not confused with top-level virsh options. */
> + while ((arg = getopt_long(argc, argv, "+hc:o:p:a:d:", opt, NULL)) != -1) {
glib has its own commandline parser
http://developer.gnome.org/glib/stable/glib-Commandline-option-parser.html
I'm not saying you have to use it, I'm merely mentioning it in case you
prefer something different from getopt.
> + char *progname;
> + switch (arg) {
> + case 'h':
> + if (!(progname = strrchr(argv[0], '/')))
> + progname = argv[0];
> + else
> + progname++;
You can also use g_path_get_basename
> +
> + conn = virConnectOpenAuth(connect_uri, virConnectAuthPtrDefault, VIR_CONNECT_RO);
> + if (!conn) {
> + print_error("Unable to connect to libvirt");
> + return EXIT_FAILURE;
> + }
> +
> + if ((caps_str = virConnectGetCapabilities(conn)) == NULL) {
> + print_error("failed to get capabilities");
> + goto cleanup;
> + }
libvirt-glib has gvir_connection_get_capabilities, I'm not sure about
virConnectOpenAuth. With that said, I guess not using libvirt-gobject is
done on purpose as libvirt-designer is not depending on it, right?
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120910/cae0422c/attachment-0001.sig>
More information about the libvir-list
mailing list