Commit 45f63dc3 authored by Guido Günther's avatar Guido Günther

Sanitize domain name

If one pastes from the output of virt-sansbox-image

  $ virt-sandbox-image list


  $ virt-sandbox-image run -c qemu:///session docker:/library/debian?tag=latest

This fails like

  Unable to start sandbox: Failed to create domain: XML error: name library/debian:qbeilwxard cannot contain '/'

so don't allow invalid chars like '/' in domain names
Signed-off-by: Guido Günther's avatarGuido Günther <>
Reviewed-by: 's avatarDaniel P. Berrange <>
parent 7280c2ee
......@@ -27,6 +27,7 @@ import hashlib
import json
import os
import os.path
import re
import shutil
import sys
import urllib2
......@@ -81,6 +82,10 @@ def prepare(args):
def random_domain_name(tmpl):
randomid = ''.join(random.choice(string.lowercase) for i in range(10))
return re.sub('[^a-z0-9-]', '_', tmpl.path[1:], re.I) + ":" + randomid
def run(args):
if args.connect is not None:
......@@ -95,8 +100,7 @@ def run(args):
name =
if name is None:
randomid = ''.join(random.choice(string.lowercase) for i in range(10))
name = tmpl.path[1:] + ":" + randomid
name = random_domain_name(tmpl)
diskfile = source.get_disk(template=tmpl,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment