马磊
2012-Dec-26 10:03 UTC
[BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
Hi, I got xen source code from http://www.xen.org/download/index_4.1.2.html . when using `xl restore`,xc_evtchn_alloc_unbound will raise this error: xc: error: do_evtchn_op: HYPERVISOR_event_channel_op failed: -1 (3 = No such process): Internal error. what does this mean and what does such process refer to? Looking forward to your reply. Thanks. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2012-Dec-26 10:19 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Wed, Dec 26, 2012 at 6:03 PM, 马磊 <aware.why@gmail.com> wrote:> Hi, > I got xen source code from > http://www.xen.org/download/index_4.1.2.html . > when using `xl restore`,xc_evtchn_alloc_unbound will raise this error: xc: > error: do_evtchn_op: HYPERVISOR_event_channel_op failed: -1 (3 = No such > process): Internal error. > what does this mean and what does such process refer to? > Looking forward to your reply. > Thanks. >The error exactly occurs at this point: (tools/libxl/libxl_dom.c) 67-int libxl__build_pre(libxl_ctx *ctx, uint32_t domid, 68 libxl_domain_build_info *info, libxl_domain_build_state *state) 69{ 70 xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus); 71 xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT); 72 xc_domain_set_memmap_limit(ctx->xch, domid, 73 (info->hvm) ? info->max_memkb : 74 (info->max_memkb + info->u.pv.slack_memkb)); 75 xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0); 76 if ( info->disable_migrate ) 77 xc_domain_disable_migrate(ctx->xch, domid); 78 79 if (info->hvm) { 80 unsigned long shadow; 81 shadow = (info->shadow_memkb + 1023) / 1024; 82 xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL); 83 } 84 85 state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0); 86 state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0); 87 return 0; 88} _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Wei Liu
2012-Dec-26 13:41 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Wed, Dec 26, 2012 at 10:19:36AM +0000, 马磊 wrote:> > > On Wed, Dec 26, 2012 at 6:03 PM, 马磊 <aware.why@gmail.com<mailto:aware.why@gmail.com>> wrote: > Hi, > I got xen source code from http://www.xen.org/download/index_4.1.2.html . > when using `xl restore`,xc_evtchn_alloc_unbound will raise this error: xc: error: do_evtchn_op: HYPERVISOR_event_channel_op failed: -1 (3 = No such process): Internal error. > what does this mean and what does such process refer to? > Looking forward to your reply. > Thanks. > > The error exactly occurs at this point: (tools/libxl/libxl_dom.c) > 67-int libxl__build_pre(libxl_ctx *ctx, uint32_t domid, > 68 libxl_domain_build_info *info, libxl_domain_build_state *state) > 69{ > 70 xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus); > 71 xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + LIBXL_MAXMEM_CONSTANT); > 72 xc_domain_set_memmap_limit(ctx->xch, domid, > 73 (info->hvm) ? info->max_memkb : > 74 (info->max_memkb + info->u.pv.slack_memkb)); > 75 xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0); > 76 if ( info->disable_migrate ) > 77 xc_domain_disable_migrate(ctx->xch, domid); > 78 > 79 if (info->hvm) { > 80 unsigned long shadow; > 81 shadow = (info->shadow_memkb + 1023) / 1024; > 82 xc_shadow_control(ctx->xch, domid, XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL); > 83 } > 84 > 85 state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0); > 86 state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0); > 87 return 0; > 88}I played with save/restore several days ago but I never saw this error. The relavent code in Xen is in xen/common/event_channel.c:do_event_channel_op Wei. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2012-Dec-26 14:45 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Wed, Dec 26, 2012 at 9:41 PM, Wei Liu <Wei.Liu2@citrix.com> wrote:> On Wed, Dec 26, 2012 at 10:19:36AM +0000, 马磊 wrote: > > > > > > On Wed, Dec 26, 2012 at 6:03 PM, 马磊 <aware.why@gmail.com<mailto: > aware.why@gmail.com>> wrote: > > Hi, > > I got xen source code from > http://www.xen.org/download/index_4.1.2.html . > > when using `xl restore`,xc_evtchn_alloc_unbound will raise this > error: xc: error: do_evtchn_op: HYPERVISOR_event_channel_op failed: -1 (3 > No such process): Internal error. > > what does this mean and what does such process refer to? > > Looking forward to your reply. > > Thanks. > > > > The error exactly occurs at this point: (tools/libxl/libxl_dom.c) > > 67-int libxl__build_pre(libxl_ctx *ctx, uint32_t domid, > > 68 libxl_domain_build_info *info, libxl_domain_build_state > *state) > > 69{ > > 70 xc_domain_max_vcpus(ctx->xch, domid, info->max_vcpus); > > 71 xc_domain_setmaxmem(ctx->xch, domid, info->target_memkb + > LIBXL_MAXMEM_CONSTANT); > > 72 xc_domain_set_memmap_limit(ctx->xch, domid, > > 73 (info->hvm) ? info->max_memkb : > > 74 (info->max_memkb + info->u.pv.slack_memkb)); > > 75 xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0); > > 76 if ( info->disable_migrate ) > > 77 xc_domain_disable_migrate(ctx->xch, domid); > > 78 > > 79 if (info->hvm) { > > 80 unsigned long shadow; > > 81 shadow = (info->shadow_memkb + 1023) / 1024; > > 82 xc_shadow_control(ctx->xch, domid, > XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION, NULL, 0, &shadow, 0, NULL); > > 83 } > > 84 > > 85 state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0); > > 86 state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0); > > 87 return 0; > > 88} > > I played with save/restore several days ago but I never saw this error. > > The relavent code in Xen is in > xen/common/event_channel.c:do_event_channel_op > > > Wei. >I said `xl restore`, not `xm restore`, and the relevant code is in src/tools/libxl. It seems that yours aren''t the same version as mine _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Wei Liu
2012-Dec-26 19:33 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Wed, Dec 26, 2012 at 02:45:46PM +0000, 马磊 wrote:> I said `xl restore`, not `xm restore`, and the relevant code is in src/tools/libxl. > It seems that yours aren't the same version as mineI didn't say xm restore either. I was referring to the generic save/restore functionality, though in fact I did use xl. And the function I told you is in Xen hypervisor source code, not part of any tool stack. Whichever tools stack you use, it will eventually issue hypercall to Xen via libxc. I don't use the same version as yours since I always plays with xen staging unstable. However I don't think allocation code has potential difference between 4.1.2 and staging unstable. Wei. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2012-Dec-27 02:12 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Thu, Dec 27, 2012 at 3:33 AM, Wei Liu <Wei.Liu2@citrix.com> wrote:> On Wed, Dec 26, 2012 at 02:45:46PM +0000, 马磊 wrote: > > I said `xl restore`, not `xm restore`, and the relevant code is in > src/tools/libxl. > > It seems that yours aren''t the same version as mine > > I didn''t say xm restore either. I was referring to the generic > save/restore functionality, though in fact I did use xl. And the > function I told you is in Xen hypervisor source code, not part of any > tool stack. > > Whichever tools stack you use, it will eventually issue hypercall to Xen > via libxc. I don''t use the same version as yours since I always plays > with xen staging unstable. However I don''t think allocation code > has potential difference between 4.1.2 and staging unstable. > > > Wei. >I got it, but the error ` xc: error: do_evtchn_op: HYPERVISOR_event_channel_op failed: -1 (3 = No such process): Internal error. ` said no such process, the system error description didn''t seem has anything to do with the following lines wich raised 85 state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0); 86 state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, 0); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Wei Liu
2012-Dec-27 12:41 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Thu, 2012-12-27 at 02:12 +0000, 马磊 wrote:> > I got it, but the error ` xc: error: do_evtchn_op: > HYPERVISOR_event_channel_op failed: -1 (3 = No such process): Internal > error. ` said no such process, the system error description > didn't seem has anything to do with the following lines wich raised > 85 state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, > 0); > 86 state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, > 0);The error code -1 is -EPERM, which means you don't have permission to issue this operation. I don't think this is a bug. There might be some problems with your setup. If you need any pointer in reading source code, I will be happy to help. Wei. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2012-Dec-28 03:13 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Thu, Dec 27, 2012 at 8:41 PM, Wei Liu <Wei.Liu2@citrix.com> wrote:> On Thu, 2012-12-27 at 02:12 +0000, 马磊 wrote: > > > > I got it, but the error ` xc: error: do_evtchn_op: > > HYPERVISOR_event_channel_op failed: -1 (3 = No such process): Internal > > error. ` said no such process, the system error description > > didn''t seem has anything to do with the following lines wich raised > > 85 state->store_port = xc_evtchn_alloc_unbound(ctx->xch, domid, > > 0); > > 86 state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, > > 0); > > The error code -1 is -EPERM, which means you don''t have permission to > issue this operation. I don''t think this is a bug. There might be some > problems with your setup. > > If you need any pointer in reading source code, I will be happy to help. > > > Wei. > > Thanks for your kindness!I looked into the functions for logging, in this case, `3 = No such process` was from `errno` and the ` HYPERVISOR_event_channel_op failed: -1 ` was from hypervisor-level error(src/xen/common/event_channel.c). In my option, that''s to say, error number of -1 was caused by hypervisor; but what was the error number of 3 caused by, dom0? Do both the two error numbers refer to the description defined in errno.h or else hypervisor has its own error description? I run `xl restore` in sudo mode, it had no reason for `EPERM`. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Wei Liu
2012-Dec-28 10:46 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Fri, 2012-12-28 at 03:13 +0000, 马磊 wrote:> > > On Thu, Dec 27, 2012 at 8:41 PM, Wei Liu <Wei.Liu2@citrix.com> wrote: > On Thu, 2012-12-27 at 02:12 +0000, 马磊 wrote: > > > > I got it, but the error ` xc: error: do_evtchn_op: > > HYPERVISOR_event_channel_op failed: -1 (3 = No such > process): Internal > > error. ` said no such process, the system error description > > didn't seem has anything to do with the following lines wich > raised > > 85 state->store_port = xc_evtchn_alloc_unbound(ctx->xch, > domid, > > 0); > > 86 state->console_port > xc_evtchn_alloc_unbound(ctx->xch, domid, > > 0); > > > The error code -1 is -EPERM, which means you don't have > permission to > issue this operation. I don't think this is a bug. There might > be some > problems with your setup. > > If you need any pointer in reading source code, I will be > happy to help. > > > Wei. > > Thanks for your kindness! > > > I looked into the functions for logging, in this case, `3 = No > such process` was from `errno` and the ` HYPERVISOR_event_channel_op > failed: -1 ` was from hypervisor-level > error(src/xen/common/event_channel.c). > In my option, that's to say, error number of -1 was caused by > hypervisor; but what was the error number of 3 caused by, dom0? > Do both the two error numbers refer to the description defined in > errno.h or else hypervisor has its own error description? >I think the two files are mostly the same, but to be sure you need to look into the source file in both Linux and Xen. You should start from the hypervisor level, find out why it returns -EPERM. Root user in Dom0 has nothing to do with privilege in hypervisor level. Wei. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2012-Dec-31 03:10 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Fri, Dec 28, 2012 at 6:46 PM, Wei Liu <Wei.Liu2@citrix.com> wrote:> On Fri, 2012-12-28 at 03:13 +0000, 马磊 wrote: > > > > > > On Thu, Dec 27, 2012 at 8:41 PM, Wei Liu <Wei.Liu2@citrix.com> wrote: > > On Thu, 2012-12-27 at 02:12 +0000, 马磊 wrote: > > > > > > I got it, but the error ` xc: error: do_evtchn_op: > > > HYPERVISOR_event_channel_op failed: -1 (3 = No such > > process): Internal > > > error. ` said no such process, the system error description > > > didn''t seem has anything to do with the following lines wich > > raised > > > 85 state->store_port = xc_evtchn_alloc_unbound(ctx->xch, > > domid, > > > 0); > > > 86 state->console_port > > xc_evtchn_alloc_unbound(ctx->xch, domid, > > > 0); > > > > > > The error code -1 is -EPERM, which means you don''t have > > permission to > > issue this operation. I don''t think this is a bug. There might > > be some > > problems with your setup. > > > > If you need any pointer in reading source code, I will be > > happy to help. > > > > > > Wei. > > > > Thanks for your kindness! > > > > > > I looked into the functions for logging, in this case, `3 = No > > such process` was from `errno` and the ` HYPERVISOR_event_channel_op > > failed: -1 ` was from hypervisor-level > > error(src/xen/common/event_channel.c). > > In my option, that''s to say, error number of -1 was caused by > > hypervisor; but what was the error number of 3 caused by, dom0? > > Do both the two error numbers refer to the description defined in > > errno.h or else hypervisor has its own error description? > > > > I think the two files are mostly the same, but to be sure you need to > look into the source file in both Linux and Xen. You should start from > the hypervisor level, find out why it returns -EPERM. Root user in Dom0 > has nothing to do with privilege in hypervisor level. > > > Wei. > > The scene is that there are more than 10 processes, each process calls `xlrestore` to start a VM where a virus sample will run to detect the sample''s behaviour about every 120 seconds. For a long time, such as 5 days or 15 days, the xen server where the processes run will raise this error with a certain probability. Maybe it has something to do with the hypervisor''s stability. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Wei Liu
2012-Dec-31 12:03 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Mon, 2012-12-31 at 03:10 +0000, 马磊 wrote:> > > > I think the two files are mostly the same, but to be sure you > need to > look into the source file in both Linux and Xen. You should > start from > the hypervisor level, find out why it returns -EPERM. Root > user in Dom0 > has nothing to do with privilege in hypervisor level. > > > Wei. > > The scene is that there are more than 10 processes, each process calls > `xl restore` to start a VM where a virus sample will run to detect the > sample's behaviour about every 120 seconds. > For a long time, such as 5 days or 15 days, the xen server where the > processes run will raise this error with a certain probability. > Maybe it has something to do with the hypervisor's stability.This is not a usual scenario. Sorry I don't know how to reproduce this. But the code path in hypervisor for evtchn_alloc_unbound is quite short, you may try adding some debug output along the path to see which step fails then report back. Wei. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2013-Jan-04 03:23 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Mon, Dec 31, 2012 at 8:03 PM, Wei Liu <Wei.Liu2@citrix.com> wrote:> On Mon, 2012-12-31 at 03:10 +0000, 马磊 wrote: > > > > > > > > I think the two files are mostly the same, but to be sure you > > need to > > look into the source file in both Linux and Xen. You should > > start from > > the hypervisor level, find out why it returns -EPERM. Root > > user in Dom0 > > has nothing to do with privilege in hypervisor level. > > > > > > Wei. > > > > The scene is that there are more than 10 processes, each process calls > > `xl restore` to start a VM where a virus sample will run to detect the > > sample''s behaviour about every 120 seconds. > > For a long time, such as 5 days or 15 days, the xen server where the > > processes run will raise this error with a certain probability. > > Maybe it has something to do with the hypervisor''s stability. > > This is not a usual scenario. Sorry I don''t know how to reproduce this. > > But the code path in hypervisor for evtchn_alloc_unbound is quite short, > you may try adding some debug output along the path to see which step > fails then report back. > > > Wei. > > BTW, it''s needed to tell you my environment background;I installed centos6.2 and then installed xen rpms from http://xenbits.xen.org/people/mayoung/EL6.xen/. At present, I''m not sure what function used to add the debug statement (is it printk?) and where to look for the debug log info (is it /var/log/message?) . The returned errno is from src/xen/common/event_channel.c 874-long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg) 875{ 876 long rc; 877 878 switch ( cmd ) 879 { 880 case EVTCHNOP_alloc_unbound: { 881 struct evtchn_alloc_unbound alloc_unbound; 882 if ( copy_from_guest(&alloc_unbound, arg, 1) != 0 ) 883 return -EFAULT; 884 rc = evtchn_alloc_unbound(&alloc_unbound); // only here returns -1(EPERM) , others return -EFAULT 885 if ( (rc == 0) && (copy_to_guest(arg, &alloc_unbound, 1) != 0) ) 886 rc = -EFAULT; /* Cleaning up here would be a mess! */ 887 break; 888 } Two statements below may affect the rc. 124-static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) 125{ 126 struct evtchn *chn; 127 struct domain *d; 128 int port; 129 domid_t dom = alloc->dom; 130 long rc; 131 132 rc = rcu_lock_target_domain_by_id(dom, &d); 133 if ( rc ) 134 return rc; 135 136 spin_lock(&d->event_lock); 137 138 if ( (port = get_free_port(d)) < 0 ) 139 ERROR_EXIT_DOM(port, d); 140 chn = evtchn_from_port(d, port); 141 142 rc = xsm_evtchn_unbound(d, chn, alloc->remote_dom); 143 if ( rc ) 144 goto out; 145 146 chn->state = ECS_UNBOUND; 147 if ( (chn->u.unbound.remote_domid = alloc->remote_dom) =DOMID_SELF ) 148 chn->u.unbound.remote_domid = current->domain->domain_id; 149 150 alloc->port = port; 151 152 out: 153 spin_unlock(&d->event_lock); 154 rcu_unlock_domain(d); 155 156 return rc; 157} _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2013-Jan-04 06:27 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Fri, Jan 4, 2013 at 11:23 AM, 马磊 <aware.why@gmail.com> wrote:> > > On Mon, Dec 31, 2012 at 8:03 PM, Wei Liu <Wei.Liu2@citrix.com> wrote: > >> On Mon, 2012-12-31 at 03:10 +0000, 马磊 wrote: >> > >> > >> > >> > I think the two files are mostly the same, but to be sure you >> > need to >> > look into the source file in both Linux and Xen. You should >> > start from >> > the hypervisor level, find out why it returns -EPERM. Root >> > user in Dom0 >> > has nothing to do with privilege in hypervisor level. >> > >> > >> > Wei. >> > >> > The scene is that there are more than 10 processes, each process calls >> > `xl restore` to start a VM where a virus sample will run to detect the >> > sample''s behaviour about every 120 seconds. >> > For a long time, such as 5 days or 15 days, the xen server where the >> > processes run will raise this error with a certain probability. >> > Maybe it has something to do with the hypervisor''s stability. >> >> This is not a usual scenario. Sorry I don''t know how to reproduce this. >> >> But the code path in hypervisor for evtchn_alloc_unbound is quite short, >> you may try adding some debug output along the path to see which step >> fails then report back. >> >> >> Wei. >> >> BTW, it''s needed to tell you my environment background; > I installed centos6.2 and then installed xen rpms from > http://xenbits.xen.org/people/mayoung/EL6.xen/. > > At present, I''m not sure what function used to add the debug statement (is > it printk?) and where to look for the debug log info (is it > /var/log/message?) . > > The returned errno is from src/xen/common/event_channel.c > 874-long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg) > > > > 875{ > > > > 876 long rc; > > > > 877 > > > > 878 switch ( cmd ) > > > > 879 { > > > > 880 case EVTCHNOP_alloc_unbound: { > > > > 881 struct evtchn_alloc_unbound alloc_unbound; > > > > 882 if ( copy_from_guest(&alloc_unbound, arg, 1) != 0 ) > > > > 883 return -EFAULT; > > > > 884 rc = evtchn_alloc_unbound(&alloc_unbound); // only > here returns -1(EPERM) , others return -EFAULT > > > 885 if ( (rc == 0) && (copy_to_guest(arg, &alloc_unbound, 1) != 0) > ) > > > 886 rc = -EFAULT; /* Cleaning up here would be a mess! */ > > > > 887 break; > > > > 888 } > > > > Two statements below may affect the rc. > 124-static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) > > > > 125{ > > > > 126 struct evtchn *chn; > > > > 127 struct domain *d; > > > > 128 int port; > > > > 129 domid_t dom = alloc->dom; > > > > 130 long rc; > > > > 131 > > > > 132 rc = rcu_lock_target_domain_by_id(dom, &d); > > > > 133 if ( rc ) > > > > 134 return rc; > > > > 135 > > > > 136 spin_lock(&d->event_lock); > > > > 137 > > > > 138 if ( (port = get_free_port(d)) < 0 ) > > > > 139 ERROR_EXIT_DOM(port, d); > > > > 140 chn = evtchn_from_port(d, port); > > > > 141 > > > > 142 rc = xsm_evtchn_unbound(d, chn, alloc->remote_dom); > > > > 143 if ( rc ) > > > > 144 goto out; > > > > 145 > > > > 146 chn->state = ECS_UNBOUND; > > > > 147 if ( (chn->u.unbound.remote_domid = alloc->remote_dom) => DOMID_SELF ) > > > 148 chn->u.unbound.remote_domid = current->domain->domain_id; > 149 > > > > 150 alloc->port = port; > > > > 151 > > > > 152 out: > > > > 153 spin_unlock(&d->event_lock); > > > > 154 rcu_unlock_domain(d); > > > > 155 > > > > 156 return rc; > > > > 157} > >I looked into it again and found that it was caused probably by src/xen/common/domain.c: 421-int rcu_lock_target_domain_by_id(domid_t dom, struct domain **d) 422{ 423 if ( dom == DOMID_SELF ) 424 { 425 *d = rcu_lock_current_domain(); 426 return 0; 427 } 428 429 if ( (*d = rcu_lock_domain_by_id(dom)) == NULL ) 430 return -ESRCH; 431 432 if ( !IS_PRIV_FOR(current->domain, *d) ) 433 { 434 rcu_unlock_domain(*d); 435 return -EPERM; 436 } 437 438 return 0; 439} the macro `IS_PRIV_FOR` is defined here src/xen/include/xen/sched.h: 638#define IS_PRIV_FOR(_d, _t) (IS_PRIV(_d) || ((_d)->target && (_d)->target == (_t))) *I couldn''t understand that what IS_PRIV_FOR means?!* _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2013-Jan-04 09:20 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Fri, 2013-01-04 at 06:27 +0000, 马磊 wrote:> > the macro `IS_PRIV_FOR` is defined here src/xen/include/xen/sched.h: > 638#define IS_PRIV_FOR(_d, _t) (IS_PRIV(_d) || ((_d)->target > && (_d)->target == (_t))) > > > I couldn't understand that what IS_PRIV_FOR means?!It tells you if domains _d has special privileges over the domain _t (the target). This is typically true of domains which are privileged in general (the IS_PRIV check, typically true only for dom0) or of stub domains for HVM which have their ->target set via XEN_DOMCTL_set_target. However this is all a red-herring since you are seeing ESRCH and not EPERM as described in my other mail. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2013-Jan-04 11:34 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Fri, Jan 4, 2013 at 5:20 PM, Ian Campbell <Ian.Campbell@citrix.com>wrote:> On Fri, 2013-01-04 at 06:27 +0000, 马磊 wrote: > > > > the macro `IS_PRIV_FOR` is defined here src/xen/include/xen/sched.h: > > 638#define IS_PRIV_FOR(_d, _t) (IS_PRIV(_d) || ((_d)->target > > && (_d)->target == (_t))) > > > > > > I couldn''t understand that what IS_PRIV_FOR means?! > > It tells you if domains _d has special privileges over the domain _t > (the target). This is typically true of domains which are privileged in > general (the IS_PRIV check, typically true only for dom0) or of stub > domains for HVM which have their ->target set via XEN_DOMCTL_set_target. > > However this is all a red-herring since you are seeing ESRCH and not > EPERM as described in my other mail. > > Ian. > > What do you mean by that ` However this is all a red-herring since you areseeing ESRCH and not EPERM as described in my other mail. ` The src/xen/include/xen/errno.h defines: 4#define EPERM 1 /* Operation not permitted */ 5#define ENOENT 2 /* No such file or directory */ 6#define ESRCH 3 /* No such process */ Besides, the xc error logging reported -1 and 3, *you said -1 only told there was an error occurring and 3 is the real reason?!* *Maybe I misunderstood your real meaning.* _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Ian Campbell
2013-Jan-04 11:42 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Fri, 2013-01-04 at 11:34 +0000, 马磊 wrote:> you said -1 only told there was an error occurring and 3 is the real > reason?!That is correct. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2013-Jan-05 04:03 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Fri, Jan 4, 2013 at 7:42 PM, Ian Campbell <Ian.Campbell@citrix.com>wrote:> On Fri, 2013-01-04 at 11:34 +0000, 马磊 wrote: > > > you said -1 only told there was an error occurring and 3 is the real > > reason?! > > That is correct. > > Ian. > > > The excution path is like this:xl_cmdimpl.c:create_domain() --> libxl_create.c:libxl_domain_create_restore() --> libxl_create.c:do_domain_create() --> libxl_create.c:domain_restore() --> libxl_create.c:libxl__build_pre() --> libxc/xc_evtchn.c:xc_evtchn_alloc_unbound() --> libxc/xc_evtchn.c:do_evtchn_op() --> libxc/xc_private.c:do_xen_hypercall() so far, it raised an error and do_xen_hypercall return -1 and errno set to be 3. You mean that 3 which is the real error code is set by ioctl() and -1 has no value of reference! But -1 is the return value of src/xen/common/event_channel.c:do_event_channel_op(), we can trace it to find that it was returned by src/xen/common/domain.c:rcu_lock_target_domain_by_id() and so it failed at this point. Why did it fail there, I can''t understand that and that blocked me. I''m greateful to be helped. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
马磊
2013-Jan-05 06:44 UTC
Re: [BUG]: when using `xl restore`,xc_evtchn_alloc_unbound will raise this error
On Fri, Jan 4, 2013 at 11:23 AM, 马磊 <aware.why@gmail.com> wrote:> > > On Mon, Dec 31, 2012 at 8:03 PM, Wei Liu <Wei.Liu2@citrix.com> wrote: > >> On Mon, 2012-12-31 at 03:10 +0000, 马磊 wrote: >> > >> > >> > >> > I think the two files are mostly the same, but to be sure you >> > need to >> > look into the source file in both Linux and Xen. You should >> > start from >> > the hypervisor level, find out why it returns -EPERM. Root >> > user in Dom0 >> > has nothing to do with privilege in hypervisor level. >> > >> > >> > Wei. >> > >> > The scene is that there are more than 10 processes, each process calls >> > `xl restore` to start a VM where a virus sample will run to detect the >> > sample''s behaviour about every 120 seconds. >> > For a long time, such as 5 days or 15 days, the xen server where the >> > processes run will raise this error with a certain probability. >> > Maybe it has something to do with the hypervisor''s stability. >> >> This is not a usual scenario. Sorry I don''t know how to reproduce this. >> >> But the code path in hypervisor for evtchn_alloc_unbound is quite short, >> you may try adding some debug output along the path to see which step >> fails then report back. >> >> >> Wei. >> >> BTW, it''s needed to tell you my environment background; > I installed centos6.2 and then installed xen rpms from > http://xenbits.xen.org/people/mayoung/EL6.xen/. > > At present, I''m not sure what function used to add the debug statement (is > it printk?) and where to look for the debug log info (is it > /var/log/message?) . > > The returned errno is from src/xen/common/event_channel.c > 874-long do_event_channel_op(int cmd, XEN_GUEST_HANDLE(void) arg) > > > > 875{ > > > > 876 long rc; > > > > 877 > > > > 878 switch ( cmd ) > > > > 879 { > > > > 880 case EVTCHNOP_alloc_unbound: { > > > > 881 struct evtchn_alloc_unbound alloc_unbound; > > > > 882 if ( copy_from_guest(&alloc_unbound, arg, 1) != 0 ) > > > > 883 return -EFAULT; > > > > 884 rc = evtchn_alloc_unbound(&alloc_unbound); // only > here returns -1(EPERM) , others return -EFAULT > > > 885 if ( (rc == 0) && (copy_to_guest(arg, &alloc_unbound, 1) != 0) > ) > > > 886 rc = -EFAULT; /* Cleaning up here would be a mess! */ > > > > 887 break; > > > > 888 } > > > Two statements below may affect the rc. > 124-static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) > > > > 125{ > > > > 126 struct evtchn *chn; > > > > 127 struct domain *d; > > > > 128 int port; > > > > 129 domid_t dom = alloc->dom; > > > > 130 long rc; > > > > 131 > > > > 132 rc = rcu_lock_target_domain_by_id(dom, &d); > > > > 133 if ( rc ) > > > > 134 return rc; > > > > 135 > > > > 136 spin_lock(&d->event_lock); > > > > 137 > > > > 138 if ( (port = get_free_port(d)) < 0 ) > > > > 139 ERROR_EXIT_DOM(port, d); > > > > 140 chn = evtchn_from_port(d, port); > > > > 141 > > > > 142 rc = xsm_evtchn_unbound(d, chn, alloc->remote_dom); > > > > 143 if ( rc ) > > > > 144 goto out; > > > > 145 > > > > 146 chn->state = ECS_UNBOUND; > > > > 147 if ( (chn->u.unbound.remote_domid = alloc->remote_dom) => DOMID_SELF ) > > > 148 chn->u.unbound.remote_domid = current->domain->domain_id; > 149 > > > > 150 alloc->port = port; > > > > 151 > > > > 152 out: > > > > 153 spin_unlock(&d->event_lock); > > > > 154 rcu_unlock_domain(d); > > > > 155 > > > > 156 return rc; > > > > 157} > >I don''t know how to debug the hypervisor... Could you give me some advice? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel