Re: [PATCH 8/8] virt-admin: Wire-up the logging APIs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 09, 2016 at 11:26:31AM -0500, John Ferlan wrote:
> 
> 
> On 11/01/2016 06:27 AM, Erik Skultety wrote:
> > Finally, now that all APIs have been introduced, wire them up to virt-admin
> > and introduce dmn-log-info and dmn-log-define commands.
> > 
> > Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
> > ---
> >  tools/virt-admin.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 141 insertions(+)
> 
> virt-admin.pod?
>

Shame on me. I'll fix this in the next version right after we reach a consensus
on all the patches.

> It seems you're defining a new set of configuration alteration comments,
> so the virt-admin.pod would have a new "CONFIGURATION" section and all
> the commands could be prefixed with "cfg-" - thoughts?
> 

We already have some cfg- stuff implemented under server- and client-, not
mentioning that we already have some aliases too, so I think it's a bit late
for this now that we follow the philosophy of placing server-related cfg stuff
under server- and client-related stuff under client-, so I think having
daemon-generic cfg stuff under daemon- might be reasonable.

Erik

> Then you'd have:
> 
> cfg-log-outputs [outputs]
> 
> where if [outputs] was provided, then you have a SET function while if
> not you have a GET function
> 
> Naturally then you'd have:
> 
> cfg-log-filters [filters]
> 
> and you could also have:
> 
> cfg-log-level [level]
> 
> which would allow adjustment of that too.
> 
> OK - so I'm looking really far forward.
> 
> 
> > 
> > diff --git a/tools/virt-admin.c b/tools/virt-admin.c
> > index b1e0c49..0bada05 100644
> > --- a/tools/virt-admin.c
> > +++ b/tools/virt-admin.c
> > @@ -971,6 +971,135 @@ cmdSrvClientsSet(vshControl *ctl, const vshCmd *cmd)
> >      goto cleanup;
> >  }
> >  
> > +/* -------------------
> > + * Command dmn-log-info
> 
> Is this dmn- or daemon-
> 
> I know this was discussed at KVM Forum, but I've forgotten...
> 
> > + * -------------------
> > + */
> > +static const vshCmdInfo info_dmn_log_info[] = {
> > +    {.name = "help",
> > +     .data = N_("view daemon's current logging settings")
> > +    },
> > +    {.name = "desc",
> > +     .data = N_("Returns all currently active logging settings on daemon. "
> > +                "These include global logging level, logging filters and "
> > +                "logging outputs.")
> > +    },
> > +    {.name = NULL}
> > +};
> > +
> > +static const vshCmdOptDef opts_dmn_log_info[] = {
> > +    {.name = "outputs",
> > +     .type = VSH_OT_BOOL,
> > +     .help = N_("query logging outputs")
> > +    },
> > +    {.name = "filters",
> > +     .type = VSH_OT_BOOL,
> > +     .help = N_("query logging filters")
> > +    },
> > +    {.name = NULL}
> > +};
> > +
> > +static bool
> > +cmdDmnLogInfo(vshControl *ctl, const vshCmd *cmd)
> > +{
> > +    bool optOutputs = vshCommandOptBool(cmd, "outputs");
> > +    bool optFilters = vshCommandOptBool(cmd, "filters");
> > +    bool all = optOutputs + optFilters == 0;
> > +    int nfilters, noutputs;
> > +    char *filters, *outputs;
> > +    vshAdmControlPtr priv = ctl->privData;
> > +
> > +    if (all || optFilters) {
> > +        if ((nfilters = virAdmConnectGetLoggingFilters(priv->conn,
> > +                                                       &filters, 0)) < 0) {
> > +            vshError(ctl, _("Unable to get daemon logging filters information"));
> > +            return false;
> > +        }
> > +    }
> > +
> > +    if (all || optOutputs) {
> > +        if ((noutputs = virAdmConnectGetLoggingOutputs(priv->conn,
> > +                                                       &outputs, 0)) < 0) {
> > +            vshError(ctl, _("Unable to get daemon logging outputs information"));
> > +            return false;
> > +        }
> > +    }
> > +
> > +    if (all || optFilters) {
> > +        vshPrintExtra(ctl, " %-15s", _("Logging filters: "));
> > +        vshPrint(ctl, "%s\n", filters);
> > +    }
> > +
> > +    if (all || optOutputs) {
> > +        vshPrintExtra(ctl, " %-15s", _("Logging outputs: "));
> > +        vshPrint(ctl, "%s\n", outputs);
> > +    }
> > +
> > +    return true;
> > +}
> > +
> > +/* -------------------------
> > + * Command daemon-log-define
> 
> Is the dmn- or daemon-
> 
> > + * -------------------------
> > + */
> > +static const vshCmdInfo info_dmn_log_define[] = {
> > +    {.name = "help",
> > +     .data = N_("change daemon's logging settings")
> > +    },
> > +    {.name = "desc",
> > +     .data = N_("Defines and installs a new set of logging settings on a daemon. "
> > +                "These include global logging level, logging filters and "
> > +                "logging outputs.")
> > +    },
> > +    {.name = NULL}
> > +};
> > +
> > +static const vshCmdOptDef opts_dmn_log_define[] = {
> > +    {.name = "outputs",
> > +     .type = VSH_OT_STRING,
> > +     .help = N_("comma separated list of logging outputs"),
> > +     .flags = VSH_OFLAG_EMPTY_OK
> > +    },
> > +    {.name = "filters",
> > +     .type = VSH_OT_STRING,
> > +     .help = N_("comma separated list of logging filters"),
> > +     .flags = VSH_OFLAG_EMPTY_OK
> > +    },
> > +    {.name = NULL}
> > +};
> > +
> > +static bool
> > +cmdDmnLogDefine(vshControl *ctl, const vshCmd *cmd)
> > +{
> > +    const char *filters = NULL;
> > +    const char *outputs = NULL;
> > +    bool optOutputs = vshCommandOptBool(cmd, "outputs");
> > +    bool optFilters = vshCommandOptBool(cmd, "filters");
> > +    vshAdmControlPtr priv = ctl->privData;
> > +
> > +    if (!(optOutputs + optFilters)) {
> > +        vshError(ctl, _("At least one of options --outputs, --filters "
> > +                        "is mandatory"));
> > +        return false;
> > +    }
> > +
> > +    if (optFilters &&
> > +        (vshCommandOptStringReq(ctl, cmd, "filters", &filters) < 0 ||
> > +        virAdmConnectSetLoggingFilters(priv->conn, filters, 0) < 0)) {
> > +        vshError(ctl, _("Unable to change daemon logging settings"));
> > +        return false;
> > +    }
> > +
> > +    if (optOutputs &&
> > +        (vshCommandOptStringReq(ctl, cmd, "outputs", &outputs) < 0 ||
> > +        virAdmConnectSetLoggingOutputs(priv->conn, outputs, 0) < 0)) {
> > +        vshError(ctl, _("Unable to change daemon logging settings"));
> > +        return false;
> > +    }
> > +
> > +    return true;
> > +}
> > +
> >  static void *
> >  vshAdmConnectionHandler(vshControl *ctl)
> >  {
> > @@ -1311,6 +1440,12 @@ static const vshCmdDef monitoringCmds[] = {
> >       .info = info_srv_clients_info,
> >       .flags = 0
> >      },
> > +    {.name = "daemon-log-info",
> > +     .handler = cmdDmnLogInfo,
> > +     .opts = opts_dmn_log_info,
> > +     .info = info_dmn_log_info,
> > +     .flags = 0
> > +    },
> >      {.name = NULL}
> >  };
> >  
> > @@ -1341,6 +1476,12 @@ static const vshCmdDef managementCmds[] = {
> >       .info = info_srv_clients_set,
> >       .flags = 0
> >      },
> > +    {.name = "daemon-log-define",
> > +     .handler = cmdDmnLogDefine,
> > +     .opts = opts_dmn_log_define,
> > +     .info = info_dmn_log_define,
> > +     .flags = 0
> > +    },
> >      {.name = NULL}
> >  };
> >  
> > 
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux