Bug 967772

Summary: Systemd container creation hasn't distinguished URI
Product: Red Hat Enterprise Linux 7 Reporter: Alex Jia <ajia>
Component: libvirt-sandboxAssignee: Daniel Berrangé <berrange>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: dallan, dyuan, gsun, mzhan, weizhan, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-sandbox-0.5.0-4.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 12:51:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alex Jia 2013-05-28 09:55:52 UTC
Description of problem:
Systemd container creation hasn't distinguished URI, if users give a non lxc:/// URI then virt-sandbox-service will create a default lxc container, it's incorrect.

Version-Release number of selected component (if applicable):
# rpm -q libvirt-sandbox libvirt kernel
libvirt-sandbox-0.2.0-1.el7.x86_64
libvirt-1.0.5-2.el7.x86_64
kernel-3.7.0-0.36.el7.x86_64


How reproducible:
always

Steps to Reproduce:
1. virt-sandbox-service -c qemu:///system create -C -u httpd.service apache1_q
2. virt-sandbox-service -c lxc:/// list


Actual results:

#  virt-sandbox-service -c lxc:/// list
apache1

# virt-sandbox-service -c qemu:///system create -C -u httpd.service apache1_q
Created sandbox container dir /var/lib/libvirt/filesystems/apache1_q
Created unit file /etc/systemd/system/apache1_q_sandbox.service
Created sandbox config /etc/libvirt-sandbox/services/apache1_q.sandbox

Notes, in fact, the host hasn't 9p module, so it should be failed to create a qemu container.

#  virt-sandbox-service -c lxc:/// list
apache1
apache1_q

 
Expected results:
fix it.

Additional info:

I think generic container creation has the same issue.


class GenericContainer(Container):
    def __init__(self, name=None, uri = "lxc:///", path = Container.DEFAULT_PATH, config=None, create=False):
        Container.__init__(self, name, uri, path, config, create)

        if create:
            self.config = LibvirtSandbox.ConfigServiceGeneric.new(name)

    def gen_filesystems(self):
        Container.gen_filesystems(self)
        self.add_bind_mount(self.dest, self.path)

    def create_generic(self):
        Container.create(self)
        self.gen_filesystems()

        if self.image:
            self.create_image()
            self.umount()
            sys.stdout.write(_("Created sandbox container image %s\n") % self.image)
        else:
            sys.stdout.write(_("Created sandbox container dir %s\n") % self.dest)
        self.save_config()

    def create(self):
        try:
            self.create_generic()
        except Exception, e:
            try:
                self.delete()
            except Exception, e2:
                pass
            raise e

Comment 2 Daniel Berrangé 2013-07-09 10:25:28 UTC
commit aa8319e3a74c9ba06dc063081b6ffd578876e8ae
Author: Wayne Sun <gsun>
Date:   Tue Jul 9 11:23:34 2013 +0100

    Fix formatting in virt-sandbox-service when raising ValueError
    
    ValueError expects the argument to be a string list, not a
    plain string. Using a plain string results in bad formatting
    when printing the error later
    
    /usr/bin/virt-sandbox-service: C
    /usr/bin/virt-sandbox-service: a
    /usr/bin/virt-sandbox-service: n
    /usr/bin/virt-sandbox-service:
    /usr/bin/virt-sandbox-service: o
    /usr/bin/virt-sandbox-service: n
    /usr/bin/virt-sandbox-service: l
    /usr/bin/virt-sandbox-service: y
    /usr/bin/virt-sandbox-service:
    /usr/bin/virt-sandbox-service: e
    /usr/bin/virt-sandbox-service: x
    /usr/bin/virt-sandbox-service: e
    /usr/bin/virt-sandbox-service: c
...snip...

Comment 3 Daniel Berrangé 2013-07-09 10:26:21 UTC
Ignore comment #2, it was from a different bug

Comment 4 Daniel Berrangé 2013-10-02 16:42:53 UTC
commit c4c57eecd397130ae8f9112cfa5faf342ca85419
Author: Daniel P. Berrange <berrange>
Date:   Wed Oct 2 17:37:06 2013 +0100

    Only allow lxc:/// URI usage with virt-sandbox-service
    
    While the goal is to allow use of qemu with
    virt-sandbox-service, this is not currently possible.
    To prevent users creating trouble for themselves, add
    a check for lxc:/// URI.
    
    Signed-off-by: Daniel P. Berrange <berrange>

Comment 6 Alex Jia 2013-10-09 10:19:20 UTC
The bug has been verified on libvirt-sandbox-0.5.0-5.el7.x86_64.

# virt-sandbox-service -c qemu:///system create -C -u httpd.service apache
/usr/bin/virt-sandbox-service: only lxc:/// URIs are currently supported

# virsh -c lxc:/// list --inactive
 Id    Name                           State
----------------------------------------------------

Comment 8 Ludek Smid 2014-06-13 12:51:21 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.