RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 790436 - libvirt runs qemu with tls options even when certs/keys are not set
Summary: libvirt runs qemu with tls options even when certs/keys are not set
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.3
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: beta
: 6.3
Assignee: Daniel Veillard
QA Contact: Virtualization Bugs
URL:
Whiteboard:
: 834443 (view as bug list)
Depends On:
Blocks: 801443
TreeView+ depends on / blocked
 
Reported: 2012-02-14 14:41 UTC by David Jaša
Modified: 2012-07-24 19:05 UTC (History)
12 users (show)

Fixed In Version: libvirt-0.9.10-3.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 801443 (view as bug list)
Environment:
Last Closed: 2012-06-20 06:48:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
example domain xml (472 bytes, text/plain)
2012-02-14 14:41 UTC, David Jaša
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 19:31:38 UTC

Description David Jaša 2012-02-14 14:41:25 UTC
Created attachment 561920 [details]
example domain xml

Description of problem:
When libvirt is asked to run domain with secure channels but no other SSL stuff enabled (spice_tls = 0 in qemu.conf), it happily runs the domain

Version-Release number of selected component (if applicable):
libvirt-0.9.9-2.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. copy attached file to local filesystem
2. make sure that port 5900 is not bound by other process
3. make sure that in /etc/libvirt/qemu.conf, spice_tls = 0
4. run virsh create <domain xml>
  
Actual results:
domain is run with spice options:
-spice port=5900,addr=0,disable-ticketing,tls-channel=main,tls-channel=inputs

Expected results:
domain is not run unless stuff for -spice x509* options of qemu-kvm is specified for the domain or system-wide

Additional info:
related bug in qemu/spice-server: bug #790421

reproducible also in Fedora

Comment 1 Christophe Fergeau 2012-02-14 14:44:11 UTC
For what it's worth, looking at the code I came up with the patch below. I still need to test it, rework the commit log, ... but this will go to the libvirt mailing list soonish if it works as expected

From a843c847cb3c6ae6749834ae510617e7475e7ecf Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau>
Date: Tue, 14 Feb 2012 15:27:36 +0100
Subject: [PATCH] Don't add SPICE TLS channels when TLS is disabled

It's possible to disable SPICE TLS in qemu.conf. When this happens,
libvirt ignores any SPICE TLS port or x509 directory that may have
been set when it builds the qemu command line to use. However, it's
not ignoring the secure channels that may have been set and adds
tls-channel arguments to qemu command line.
qemu doesn't report an error when this happens, but I'm not sure yet
it behaves sanely when we do that, so better not to add these arguments.
---
 src/qemu/qemu_command.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 99d7129..30fb3b1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5286,8 +5286,9 @@ qemuBuildCommandLine(virConnectPtr conn,
             int mode = def->graphics[0]->data.spice.channels[i];
             switch (mode) {
             case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_SECURE:
-                virBufferAsprintf(&opt, ",tls-channel=%s",
-                                  virDomainGraphicsSpiceChannelNameTypeToString(i));
+                if (driver->spiceTLS)
+                    virBufferAsprintf(&opt, ",tls-channel=%s",
+                                      virDomainGraphicsSpiceChannelNameTypeToString(i));
                 break;
             case VIR_DOMAIN_GRAPHICS_SPICE_CHANNEL_MODE_INSECURE:
                 virBufferAsprintf(&opt, ",plaintext-channel=%s",
-- 
1.7.7.6

Comment 3 Eric Blake 2012-02-14 21:12:28 UTC
Is it better to silently ignore the user's request for a secure channel, or should libvirt be erroring out on any attempt to start a domain whose XML requested a secure channel when qemu.conf disabled TLS?

Comment 4 David Jaša 2012-02-15 09:48:26 UTC
I think that error is in this case appropriate. Current behaviour leads to inaccessible guest via Spice (because of bug #790421) which is hardly better than plain error.

Comment 5 Christophe Fergeau 2012-02-15 17:18:52 UTC
See my take on this at
https://www.redhat.com/archives/libvir-list/2012-February/msg00675.html :

"My initial feeling was that we should error out. However, I don't think
it's realistic at this point:
* oVirt is already disabling TLS in qemu.conf if the admin says he does not
  want it during engine-setup, but oVirt still adds the TLS port/secure
  channels to its libvirt VMs even when TLS is disabled. They probably
  won't be that happy if libvirt starts erroring out here. Though we can
  also argue that it's a bug on their side, and that the VMs they start this
  way (with TLS XML bits but TLS disabled in the conf file) are not usable
  anyway because of these extra tls-channel options
* this will also be annoying if someone has setup a bunch of VMs with TLS
  parameters and then decides to change the TLS setting in qemu.conf, these
  VMs will suddenly fail to start until their conf is modified

Because of that, I think we should unfortunately just ignore these TLS bits
when TLS is disabled. We can log a warning though when we detect this. Once
again, regardless of what we decide to do, it's better done in a separate
patch."

Moreover, we currently silently ignore TLS ports set in the XML config when TLS
is disabled in qemu.conf so this would need changing there too.

Comment 6 Eric Blake 2012-02-15 17:58:44 UTC
Due to back-compat for older oVirt requesting secure channels at the same time they disable TLS, maybe we need to introduce a third mode for each spice channel:

mode='insecure' - don't bother with security
mode='secure' - use security if tls is available, but fall back to insecure
mode='mandatory-secure' - use security, and error out if tls not available

Comment 7 Dave Allan 2012-02-16 02:19:07 UTC
(In reply to comment #4)
> I think that error is in this case appropriate. Current behaviour leads to
> inaccessible guest via Spice (because of bug #790421) which is hardly better
> than plain error.

Given that, I'd favor avoiding the third mode and just going with refusing to start the guest.  We should make sure that's ok with the broader ovirt team, though.

Comment 8 David Jaša 2012-02-16 19:39:06 UTC
(In reply to comment #6)
> mode='insecure' - don't bother with security

By this, you mean plaintext-only setting, or provide tls if certs/keys are available?

> mode='secure' - use security if tls is available, but fall back to insecure

What does falling back mean here? Provide both and let client choose or provide plaintext channel only if tls-port or x509 stuff is not set?

> mode='mandatory-secure'

^^^ FWIW, this is what RHEV means by mode='secure'. They _do want_ to enforce main and input channels to TLS. oVirt's feature of hosts without mandatory TLS is quite new and clearly not yet stabilized.

Another consideration is that sometimes, you could want some channels to be mandatory insecure, like display + playback on hosts that do not support aes-ni.

Given the facts above, I'd propose going with these four modes:

* mode='insecure' - provide plaintext-only (-spice plaintext-channel=...)
* mode='...' - provide both if BOTH x509 stuff is set and TLS port
               will get alocated, else provide plaintext-only
* mode='...' - provide both tls and plaintext, error out if x509 stuff is
               not set
* mode='secure' - provide TLS channel only, error out if x509 stuff is not set

The secure mode name is chosen with respect to compatibility with RHEV usage and I didn't manage to name the middle ones sanely. When spice_tls is == 0, second mode should be default, when spice_tls == 1, third mode should be default.

Comment 9 David Jaša 2012-02-16 19:41:41 UTC
minor correction:

(In reply to comment #8)
> and I didn't manage to name the middle ones sanely. When spice_tls is == 0,
> second mode should be default, when spice_tls == 1, third mode should be
> default.

with spice_tls set to 1, main and inputs channels should default to fourth mode, the rest to third.

Comment 10 Eric Blake 2012-02-16 20:12:27 UTC
Would you mind making these same suggestions on the upstream list, for a wider audience?  https://www.redhat.com/archives/libvir-list/2012-February/msg00711.html

Comment 11 David Jaša 2012-02-17 23:30:13 UTC
(In reply to comment #10)
> Would you mind making these same suggestions on the upstream list, for a wider
> audience? 
> https://www.redhat.com/archives/libvir-list/2012-February/msg00711.html

Done: https://www.redhat.com/archives/libvir-list/2012-February/msg00775.html

Comment 16 Huang Wenlong 2012-02-29 05:36:23 UTC
Verify this bug with libvirt-0.9.10-3.el6.x86_64

set /etc/libvirt/qemu.conf   spice_tls = 0  then restart libvirtd 


#virsh define tls.xml 

<domain type='kvm'>
  <name>auto-tls-port</name>
  <memory>65536</memory>
  <os>
    <type arch='x86_64' machine='pc'>hvm</type>
  </os>
  <devices>
    <graphics type='spice' port='5900' tlsPort='-1' autoport='yes' listen='0' keymap='en-us' passwdValidTo='2012-02-14T13:45:54' connected='disconnect'>
      <listen type='address' address='0'/>
      <channel name='main' mode='secure'/>
      <channel name='inputs' mode='secure'/>
    </graphics>
  </devices>
</domain>


# virsh start auto-tls-port 
error: Failed to start domain auto-tls-port
error: unsupported configuration: spice secure channels set in XML configuration, but TLS is disabled in qemu.conf

Comment 17 David Jaša 2012-03-08 11:35:41 UTC
Back to ASSIGNED, current check stops qemu even in case when 

$ grep -A2 'graphics type' rhel6.xml 
    <graphics type='spice' port='3005' autoport='no' listen='0.0.0.0'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
$ LANG= virsh domxml-to-native --format qemu-argv --xml rhel6.xml 
error: unsupported configuration: spice TLS port set in XML configuration, but TLS is disabled in qemu.conf

The behaviour is the same under root and libvirtd.log doesn't provide any insight even with debug = 1.

Comment 18 David Jaša 2012-03-08 11:37:41 UTC
Version information:
$ rpm -qa | grep 'libvirt*\|qemu-kvm*'
qemu-kvm-0.12.1.2-2.236.el6.x86_64
libvirt-0.9.10-3.el6.x86_64
qemu-kvm-debuginfo-0.12.1.2-2.236.el6.x86_64
qemu-kvm-tools-0.12.1.2-2.236.el6.x86_64
libvirt-python-0.9.10-3.el6.x86_64
libvirt-client-0.9.10-3.el6.x86_64

Comment 19 Huang Wenlong 2012-03-08 12:06:52 UTC
If set autoport='no' and not set tlsPort in domain xml ,in this case the tlsPort is  automatic allocated , so it reports TLS error message.

Comment 20 David Jaša 2012-03-08 12:21:19 UTC
(In reply to comment #19)
> If set autoport='no' and not set tlsPort in domain xml ,in this case the
> tlsPort is  automatic allocated , so it reports TLS error message.

Hi Wenlong,

Is this behaviour documented somewhere? I can not find it in libvirt documentation and when writing the configuration with no mention of tlsPort, I would expect libvirt not to care about it.

Comment 21 Huang Wenlong 2012-03-08 12:30:56 UTC
(In reply to comment #20)
> (In reply to comment #19)
> > If set autoport='no' and not set tlsPort in domain xml ,in this case the
> > tlsPort is  automatic allocated , so it reports TLS error message.
> 
> Hi Wenlong,
> 
> Is this behaviour documented somewhere? I can not find it in libvirt
> documentation and when writing the configuration with no mention of tlsPort, I
> would expect libvirt not to care about it.

Hi,David

Sorry ,I can not find document about this,you'd better needinfo developer of libvirt .

Wenlong

Comment 22 Michal Privoznik 2012-03-08 13:31:05 UTC
I think this is clearly a bug;

From our parsing code:

src/conf/domain_conf.c:5992:        tlsPort = virXMLPropString(node, "tlsPort");
src/conf/domain_conf.c:5993:        if (tlsPort) {
src/conf/domain_conf.c:5994:            if (virStrToLong_i(tlsPort, NULL, 10, &def->data.spice.tlsPort) < 0) {
src/conf/domain_conf.c-5995-                virDomainReportError(VIR_ERR_INTERNAL_ERROR,
src/conf/domain_conf.c:5996:                                     _("cannot parse spice tlsPort %s"), tlsPort);
src/conf/domain_conf.c:5997:                VIR_FREE(tlsPort);
src/conf/domain_conf.c-5998-                goto error;
src/conf/domain_conf.c-5999-            }
src/conf/domain_conf.c:6000:            VIR_FREE(tlsPort);
src/conf/domain_conf.c-6001-        } else {
src/conf/domain_conf.c:6002:            def->data.spice.tlsPort = 0;
src/conf/domain_conf.c-6003-        }

However, if we build qemu command line we test tlsPort against -1:

src/qemu/qemu_command.c:5377:        if (def->graphics[0]->data.spice.tlsPort != -1) {
src/qemu/qemu_command.c-5378-            if (!driver->spiceTLS) {
src/qemu/qemu_command.c-5379-                qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
src/qemu/qemu_command.c-5380-                                _("spice TLS port set in XML configuration,"
src/qemu/qemu_command.c-5381-                                  " but TLS is disabled in qemu.conf"));
src/qemu/qemu_command.c-5382-                goto error;
src/qemu/qemu_command.c-5383-            }
src/qemu/qemu_command.c-5384-            virBufferAsprintf(&opt, ",tls-port=%u",
src/qemu/qemu_command.c:5385:                              def->graphics[0]->data.spice.tlsPort);
src/qemu/qemu_command.c-5386-        }


I've proposed patch upstream:

https://www.redhat.com/archives/libvir-list/2012-March/msg00332.html

Comment 23 Michal Privoznik 2012-03-08 13:36:53 UTC
Sorry for bad formatting. Maybe this time I've leaned Bugzilla gods onto my side:

From our parsing code:

tlsPort = virXMLPropString(node, "tlsPort");
if (tlsPort) {
    if (virStrToLong_i(tlsPort, NULL, 10, &def->data.spice.tlsPort) < 0) {
        virDomainReportError(VIR_ERR_INTERNAL_ERROR,
                             _("cannot parse spice tlsPort %s"), tlsPort);
        VIR_FREE(tlsPort);
        goto error;
    }
    VIR_FREE(tlsPort);
} else {
    def->data.spice.tlsPort = 0;
}

However, if we build qemu command line we test tlsPort against -1:

if (def->graphics[0]->data.spice.tlsPort != -1) {
    if (!driver->spiceTLS) {
        qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("spice TLS port set in XML configuration,"
                          " but TLS is disabled in qemu.conf"));
        goto error;
    }
    virBufferAsprintf(&opt, ",tls-port=%u",
                      def->graphics[0]->data.spice.tlsPort);
}

Comment 24 Michal Privoznik 2012-03-08 14:48:06 UTC
Re-thinking this, we should move this back to VERIFIED as the initial problem is fixed. For the issue David is mentioning in comment #17 I've created a separate bug 801443.

Comment 25 Huang Wenlong 2012-03-08 15:26:30 UTC
Set Verified this bug due to comment #24

Comment 27 errata-xmlrpc 2012-06-20 06:48:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0748.html

Comment 28 Dave Allan 2012-07-24 19:05:19 UTC
*** Bug 834443 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.