Bug 967772 - Systemd container creation hasn't distinguished URI
Systemd container creation hasn't distinguished URI
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt-sandbox (Show other bugs)
7.0
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Daniel Berrange
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-28 05:55 EDT by Alex Jia
Modified: 2014-06-13 08:51 EDT (History)
6 users (show)

See Also:
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 08:51:21 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alex Jia 2013-05-28 05:55:52 EDT
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 Berrange 2013-07-09 06:25:28 EDT
commit aa8319e3a74c9ba06dc063081b6ffd578876e8ae
Author: Wayne Sun <gsun@redhat.com>
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 Berrange 2013-07-09 06:26:21 EDT
Ignore comment #2, it was from a different bug
Comment 4 Daniel Berrange 2013-10-02 12:42:53 EDT
commit c4c57eecd397130ae8f9112cfa5faf342ca85419
Author: Daniel P. Berrange <berrange@redhat.com>
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@redhat.com>
Comment 6 Alex Jia 2013-10-09 06:19:20 EDT
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 08:51:21 EDT
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.

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