]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Add option '--no-pkttyagent'
authorJens Schmidt <farblos@vodafonemail.de>
Sat, 17 May 2025 16:32:16 +0000 (18:32 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 19 May 2025 07:08:14 +0000 (09:08 +0200)
In scripts repeated execution of virsh can result in a lot of
journal noise when pkttyagent gets registered with polkitd each
time.

Closes: https://gitlab.com/libvirt/libvirt/-/issues/757
Signed-off-by: Jens Schmidt <farblos@vodafonemail.de>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
docs/manpages/virsh.rst
tools/virsh.c
tools/vsh.h

index 0a54f6deff2ef0f4ea9587b209a8ca3b3a64cd42..3a00778467bbd5c5ca98ee76428e5395dd994672 100644 (file)
@@ -140,6 +140,14 @@ Output elapsed time information for each command.
 
 
 
+- ``--no-pkttyagent``
+
+Do not register ``pkttyagent`` as authentication agent with the
+polkit system daemon, even if ``virsh`` has been started from a
+terminal.
+
+
+
 - ``-v``, ``--version[=short]``
 
 Ignore all other arguments, and prints the version of the libvirt library
index 800e280c7a55160fd2203eb1278d5d49bcf74624..c893216637d26f09a6afcea701a2c0821a839200 100644 (file)
@@ -117,7 +117,8 @@ virshConnect(vshControl *ctl, const char *uri, bool readonly)
         keepalive_forced = true;
     }
 
-    if (virPolkitAgentAvailable() &&
+    if (!ctl->no_pkttyagent &&
+        virPolkitAgentAvailable() &&
         !(pkagent = virPolkitAgentCreate()))
         virResetLastError();
 
@@ -446,6 +447,7 @@ virshUsage(void)
                       "    -q | --quiet            quiet mode\n"
                       "    -r | --readonly         connect readonly\n"
                       "    -t | --timing           print timing information\n"
+                      "         --no-pkttyagent    suppress registration of pkttyagent\n"
                       "    -v                      short version\n"
                       "    -V                      long version\n"
                       "         --version[=TYPE]   version, TYPE is short or long (default short)\n"
@@ -642,6 +644,7 @@ virshParseArgv(vshControl *ctl, int argc, char **argv)
         { "quiet", no_argument, NULL, 'q' },
         { "readonly", no_argument, NULL, 'r' },
         { "timing", no_argument, NULL, 't' },
+        { "no-pkttyagent", no_argument, NULL, 0 },
         { "version", optional_argument, NULL, 'v' },
         { NULL, 0, NULL, 0 },
     };
@@ -739,6 +742,14 @@ virshParseArgv(vshControl *ctl, int argc, char **argv)
         case 'V':
             virshShowVersion(ctl);
             exit(EXIT_SUCCESS);
+        case 0:
+            if (STREQ(opt[longindex].name, "no-pkttyagent")) {
+                ctl->no_pkttyagent = true;
+                break;
+            } else {
+                vshError(ctl, "%s", _("unknown option"));
+                exit(EXIT_FAILURE);
+            }
         case ':':
             for (i = 0; opt[i].name != NULL; i++) {
                 if (opt[i].val == optopt)
index 8b87c00ff4bad9faf4017e731345f1a69c57f9fc..3b75216e1107d60ba2fecf42a53dc1db56c97405 100644 (file)
@@ -200,6 +200,7 @@ struct _vshControl {
     bool imode;                 /* interactive mode? */
     bool quiet;                 /* quiet mode */
     bool timing;                /* print timing info? */
+    bool no_pkttyagent;         /* suppress registration of pkttyagent? */
     int debug;                  /* print debug messages? */
     char *logfile;              /* log file name */
     int log_fd;                 /* log file descriptor */