Skip to contentSkip to conversation

xl: Check invalid domid in find_domain()

PATCH In review Yang Hongyang 2 participants 4 messages May 13, 2010 – May 18, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 xl: Check invalid domid in find_domain()

If domain id is invalid, find_domain should return error because the specified domain does not exist.

tools/libxl/xl_cmdimpl.c +5 -1
diff -r a49dfaa986b0 tools/libxl/xl_cmdimpl.c
@@ -137,7 +137,11 @@
         fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc);
         exit(2);
     }
-    common_domname = was_name ? p : 0;
+    common_domname = was_name ? p : libxl_domid_to_name(&ctx, domid);
+    if (!common_domname) {
+        fprintf(stderr, "%s is an invalid domain identifier.\n", p);
+        exit(2);
+    }
 }
 
 #define LOG(_f, _a...)   dolog(__FILE__, __LINE__, __func__, _f "\n", ##_a)
Signature · 2 lines
Regards
Yang Hongyang
#1 lore raw
Quoted 3 lines · Yang Hongyang

If domain id is invalid, find_domain should return error because the specified domain does not exist.

I think this patch is causing some regressions. For example, I can no longer rename dom0:

sh-4.0# xl list 0
Name ID Mem VCPUs State Time(s)
(null) 0 3321 4 r-- 741.7
sh-4.0# xl rename 0 dom0
0 is an invalid domain identifier.

I haven't specifically worked out what's failing here...

J

Quoted 20 lines

diff -r a49dfaa986b0 tools/libxl/xl_cmdimpl.c

tools/libxl/xl_cmdimpl.c +5 -1
@@ -137,7 +137,11 @@
         fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc);
         exit(2);
     }
-    common_domname = was_name ? p : 0;
+    common_domname = was_name ? p : libxl_domid_to_name(&ctx, domid);
+    if (!common_domname) {
+        fprintf(stderr, "%s is an invalid domain identifier.\n", p);
+        exit(2);
+    }
 }
 
 #define LOG(_f, _a...)   dolog(__FILE__, __LINE__, __func__, _f "\n", ##_a)
#2 lore raw

Hi jeremy,

Quoted 8 lines · Jeremy Fitzhardinge
Quoted 3 lines · Yang Hongyang

If domain id is invalid, find_domain should return error because the specified domain does not exist.

I think this patch is causing some regressions. For example, I can no longer rename dom0:

Quoted 7 lines

sh-4.0# xl list 0
Name ID Mem VCPUs State Time(s)
(null) 0 3321 4 r-- 741.7
sh-4.0# xl rename 0 dom0
0 is an invalid domain identifier.

I haven't specifically worked out what's failing here...

I think there's some other problems in the kernel or xl. First of all, the (null) name should not appera in the list, if there is, then this VM is not fullly destoried I think, but when I'm trying to destory the vm, libxl reported errors and the VM still exists. Second of all, I notice that your DOM0's name is (null), and State is running, how could you do that? I manully tryed out 'xl rename "(null)"' to rename DOM0's name to (null), but after that I can still rename the name back with my patch.

We often met the "(null)" problem's either, but never met that problem on DOM0... And the "(null)" problem often happened after "xl destory". We can not figure out a method to reproduce this problem.

Below is the output(without this patch):

[root@centos libxl]# xl list
Name ID Mem VCPUs State Time(s)

Domain-0                                     0  1024     2        r--    250.2
(null)                                       2     0     1        --d  52657.4
Mini-OS                                      4    32     1        r--      0.0

[root@centos libxl]# xl destroy 2
[0] libxl.c:764:libxl_domain_destroy: xs_rm failed for /xapi/2: No such file or directory [root@centos libxl]# xl rename 2 a
[root@centos libxl]# xl list
Name ID Mem VCPUs State Time(s)

Domain-0                                     0  1024     2        r--    251.9
a                                            2     0     1        --d  52657.4
Mini-OS                                      4    32     1        r--      0.0

[root@centos libxl]# xl destroy 2
[0] libxl.c:764:libxl_domain_destroy: xs_rm failed for /xapi/2: No such file or directory [root@centos libxl]# xl destroy a
a is an invalid domain identifier (rc=-1)
[root@centos libxl]#
===================================================================================
with the patch:

[root@centos libxl]# xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 2 r-- 21.9
[root@centos libxl]# xl rename 0 "(null)"
[root@centos libxl]# xl list
Name ID Mem VCPUs State Time(s)
(null) 0 1024 2 r-- 22.0
[root@centos libxl]# xl rename 0 Domain-0
[root@centos libxl]# xl list
Name ID Mem VCPUs State Time(s)
Domain-0 0 1024 2 r-- 22.2
[root@centos libxl]#

Quoted 26 lines

J

Quoted 20 lines

diff -r a49dfaa986b0 tools/libxl/xl_cmdimpl.c

tools/libxl/xl_cmdimpl.c +5 -1
@@ -137,7 +137,11 @@
         fprintf(stderr, "%s is an invalid domain identifier (rc=%d)\n", p, rc);
         exit(2);
     }
-    common_domname = was_name ? p : 0;
+    common_domname = was_name ? p : libxl_domid_to_name(&ctx, domid);
+    if (!common_domname) {
+        fprintf(stderr, "%s is an invalid domain identifier.\n", p);
+        exit(2);
+    }
 }
 
 #define LOG(_f, _a...)   dolog(__FILE__, __LINE__, __func__, _f "\n", ##_a)
Signature · 2 lines
Regards
Yang Hongyang
#3 lore raw
Quoted 19 lines · Yang Hongyang

Hi jeremy,

Quoted 15 lines · Jeremy Fitzhardinge
Quoted 4 lines · Yang Hongyang

If domain id is invalid, find_domain should return error because the specified domain does not exist.

I think this patch is causing some regressions. For example, I can no longer rename dom0:

sh-4.0# xl list 0
Name ID Mem VCPUs State Time(s)
(null) 0 3321 4 r-- 741.7
sh-4.0# xl rename 0 dom0
0 is an invalid domain identifier.

Quoted 3 lines
Quoted 2 lines

I haven't specifically worked out what's failing here...

I think there's some other problems in the kernel or xl.

The kernel has nothing to do with domain management, so the problem must either be in usermode or in Xen (but since Xen is known to work...).

Quoted 8 lines

First of all, the
(null) name should not appera in the list, if there is, then this VM is not fullly destoried I think, but when I'm trying to destory the vm, libxl reported errors and the VM still exists. Second of all, I notice that your DOM0's name is (null), and State is running, how could you do that? I manully tryed out 'xl rename "(null)"' to rename DOM0's name to (null), but after that I can still rename the name back with my patch.

I boot my machine without ever having run xend. When I first log in:

# oxenstored
# xl list
Name                                        ID   Mem VCPUs	State	Time(s)
(null)                                       0  3321     4        r--    143.1

But the problem is that "xl" doesn't let me operate on dom0 at all. For example, if I do:

# xl mem-set 0 2000000
0 is an invalid domain identifier.
Quoted 4 lines

We often met the "(null)" problem's either, but never met that problem on DOM0... And the "(null)" problem often happened after "xl destory". We can not figure out a method to reproduce this problem.

I see this regularly, especially after doing a "xl save" on a domain.

J